Skip to content

Commit 9e3f41a

Browse files
committed
Try to auto-generate BPF objects on PR
1 parent 79f10ff commit 9e3f41a

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Auto-generate and commit BPF files
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
7+
permissions:
8+
contents: write # Required for creating PRs
9+
10+
jobs:
11+
generate-and-commit:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: "Checkout repo"
16+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
17+
with:
18+
persist-credentials: false
19+
20+
- name: Run docker-generate
21+
run: make docker-generate
22+
23+
- name: Add generated files
24+
run: |
25+
find . -name "*_bpfel*" -not -path "**/vendor/*" | xargs git add -f
26+
27+
- name: "Create/update PR"
28+
id: git-check
29+
env:
30+
GITHUB_TOKEN: ${secrets.GITHUB_TOKEN}
31+
run: |
32+
if git diff --staged --quiet; then
33+
echo "No changes to commit"
34+
echo "changes=true" >> $GITHUB_OUTPUT
35+
else
36+
echo "Changes detected"
37+
echo "changes=false" >> $GITHUB_OUTPUT
38+
fi
39+
40+
- uses: actions/create-github-app-token@d72941d797fd3113feb6b93fd0dec494b13a2547 # v1.12.0
41+
id: generate-token
42+
if: steps.git-check.outputs.changes == 'true'
43+
with:
44+
app-id: ${{ vars.OTELBOT_APP_ID }}
45+
private-key: ${{ secrets.OTELBOT_PRIVATE_KEY }}
46+
- name: "Create/update PR"
47+
if: steps.git-check.outputs.changes == 'true'
48+
env:
49+
# not using secrets.GITHUB_TOKEN since pull requests from that token do not run workflows
50+
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
51+
run: |
52+
git config user.name otelbot
53+
git config user.email [email protected]
54+
55+
git commit -m "Auto-generate BPF files"
56+
branch="${GITHUB_HEAD_REF}"
57+
git push origin HEAD:$branch

0 commit comments

Comments
 (0)