Skip to content

Commit 05bace3

Browse files
Merge pull request #202 from chiukapoor/dispatch-job
Add GitHub App token generation and dispatch job for System Agent Upgrade workflow.
2 parents b8c28d0 + dbf910d commit 05bace3

File tree

1 file changed

+57
-1
lines changed

1 file changed

+57
-1
lines changed

Diff for: .github/workflows/release.yaml

+57-1
Original file line numberDiff line numberDiff line change
@@ -271,9 +271,26 @@ jobs:
271271
- merge-suc
272272
permissions:
273273
contents: write # needed for creating the GH release
274+
id-token: write
274275
steps:
276+
- name: Read App Secrets
277+
uses: rancher-eio/read-vault-secrets@main
278+
with:
279+
secrets: |
280+
secret/data/github/repo/${{ github.repository }}/github/app-credentials appId | APP_ID ;
281+
secret/data/github/repo/${{ github.repository }}/github/app-credentials privateKey | PRIVATE_KEY
282+
283+
- name: Create App Token
284+
uses: actions/create-github-app-token@v1
285+
id: app-token
286+
with:
287+
app-id: ${{ env.APP_ID }}
288+
private-key: ${{ env.PRIVATE_KEY }}
289+
275290
- name: Checkout code
276291
uses: actions/checkout@v4
292+
with:
293+
token: ${{ steps.app-token.outputs.token }}
277294

278295
- name: Download binary
279296
uses: actions/download-artifact@v4
@@ -299,6 +316,45 @@ jobs:
299316
300317
- name: Create release
301318
env:
302-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
319+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
303320
run:
304321
gh release create ${{ github.ref_name }} --verify-tag --generate-notes dist/*
322+
323+
dispatch:
324+
permissions:
325+
contents: read
326+
id-token: write
327+
runs-on: ubuntu-latest
328+
timeout-minutes: 10
329+
needs: github_release
330+
strategy:
331+
fail-fast: false
332+
matrix:
333+
target-branch: [release/v2.9, release/v2.10, main]
334+
steps:
335+
- name: Read App Secrets
336+
uses: rancher-eio/read-vault-secrets@main
337+
with:
338+
secrets: |
339+
secret/data/github/repo/${{ github.repository }}/github/app-credentials appId | APP_ID ;
340+
secret/data/github/repo/${{ github.repository }}/github/app-credentials privateKey | PRIVATE_KEY
341+
342+
- name: Create App Token
343+
uses: actions/create-github-app-token@v1
344+
id: app-token
345+
with:
346+
app-id: ${{ env.APP_ID }}
347+
private-key: ${{ env.PRIVATE_KEY }}
348+
349+
- name: Checkout code
350+
uses: actions/checkout@v4
351+
with:
352+
token: ${{ steps.app-token.outputs.token }}
353+
354+
- name: Run dispatch
355+
run: |
356+
ACTION_TARGET_BRANCH=${{ matrix.target-branch }}
357+
echo "Dispatching to $ACTION_TARGET_BRANCH branch of rancher/rancher"
358+
gh workflow run "System Agent Upgrade" --repo rancher/rancher --ref $ACTION_TARGET_BRANCH -F system_agent_version=${{ github.ref_name }} -F source_author=${{ github.actor }}
359+
env:
360+
GH_TOKEN: ${{ steps.app-token.outputs.token }}

0 commit comments

Comments
 (0)