Skip to content

Commit 77b6760

Browse files
github actions: Use Github APP authentication instead of personal tokens
PRs that were created by this workflow were using my name due to the personal github token being used here. Use the latest Github App Authentication method set up by TJ for us. Signed-off-by: Shreeya Patel <spatel@ciq.com>
1 parent 7bd91bc commit 77b6760

File tree

1 file changed

+40
-5
lines changed

1 file changed

+40
-5
lines changed

.github/workflows/kernel-build-and-test-x86_64.yml

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ jobs:
1616
if: "!contains(github.event.head_commit.message, '[skip ci]') && !contains(github.event.head_commit.message, '[ci skip]')"
1717

1818
steps:
19+
- name: Generate GitHub App token
20+
id: generate_token
21+
uses: actions/create-github-app-token@v1
22+
with:
23+
app-id: ${{ secrets.APP_ID }}
24+
private-key: ${{ secrets.APP_PRIVATE_KEY }}
25+
1926
- name: Checkout kernel source
2027
uses: actions/checkout@v4
2128
with:
@@ -28,7 +35,7 @@ jobs:
2835
repository: ctrliq/kernel-container-build
2936
ref: automated-testing-v1
3037
path: kernel-container-build
31-
token: ${{ secrets.PRIVATE_REPO_ACCESS_TOKEN }}
38+
token: ${{ steps.generate_token.outputs.token }}
3239

3340
# Host deps + KVM / FUSE validation
3441
- name: Install host dependencies & verify KVM/FUSE
@@ -92,13 +99,20 @@ jobs:
9299
needs: build
93100

94101
steps:
102+
- name: Generate GitHub App token
103+
id: generate_token
104+
uses: actions/create-github-app-token@v1
105+
with:
106+
app-id: ${{ secrets.APP_ID }}
107+
private-key: ${{ secrets.APP_PRIVATE_KEY }}
108+
95109
- name: Checkout kernel-container-build (test branch)
96110
uses: actions/checkout@v4
97111
with:
98112
repository: ctrliq/kernel-container-build
99113
ref: automated-testing-v1
100114
path: kernel-container-build
101-
token: ${{ secrets.PRIVATE_REPO_ACCESS_TOKEN }}
115+
token: ${{ steps.generate_token.outputs.token }}
102116

103117
- name: Install host dependencies
104118
run: |
@@ -146,13 +160,20 @@ jobs:
146160
needs: boot
147161

148162
steps:
163+
- name: Generate GitHub App token
164+
id: generate_token
165+
uses: actions/create-github-app-token@v1
166+
with:
167+
app-id: ${{ secrets.APP_ID }}
168+
private-key: ${{ secrets.APP_PRIVATE_KEY }}
169+
149170
- name: Checkout kernel-container-build (test branch)
150171
uses: actions/checkout@v4
151172
with:
152173
repository: ctrliq/kernel-container-build
153174
ref: automated-testing-v1
154175
path: kernel-container-build
155-
token: ${{ secrets.PRIVATE_REPO_ACCESS_TOKEN }}
176+
token: ${{ steps.generate_token.outputs.token }}
156177

157178
- name: Install host dependencies
158179
run: |
@@ -226,10 +247,17 @@ jobs:
226247
sudo apt-get install -y gh
227248
fi
228249
250+
- name: Generate GitHub App token for comparison
251+
id: generate_token_compare
252+
uses: actions/create-github-app-token@v1
253+
with:
254+
app-id: ${{ secrets.APP_ID }}
255+
private-key: ${{ secrets.APP_PRIVATE_KEY }}
256+
229257
- name: Determine base branch for comparison
230258
id: base_branch
231259
env:
232-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
260+
GH_TOKEN: ${{ steps.generate_token_compare.outputs.token }}
233261
run: |
234262
BASE_BRANCH=""
235263
BRANCH_NAME="${{ github.ref_name }}"
@@ -487,9 +515,16 @@ jobs:
487515
git checkout origin/main -- .github/scripts/create-pr-body.sh
488516
chmod +x .github/scripts/create-pr-body.sh
489517
518+
- name: Generate GitHub App token
519+
id: generate_token
520+
uses: actions/create-github-app-token@v1
521+
with:
522+
app-id: ${{ secrets.APP_ID }}
523+
private-key: ${{ secrets.APP_PRIVATE_KEY }}
524+
490525
- name: Create Pull Request
491526
env:
492-
GH_TOKEN: ${{ secrets.PRIVATE_REPO_ACCESS_TOKEN }}
527+
GH_TOKEN: ${{ steps.generate_token.outputs.token }}
493528
run: |
494529
# Reuse base branch from compare-results stage (already computed)
495530
BASE_BRANCH="${{ needs.compare-results.outputs.base_branch }}"

0 commit comments

Comments
 (0)