Skip to content

Commit 2d8790a

Browse files
authored
Merge pull request #219 from chiukapoor/github-app-token
Add support for app token to acquire `GITHUB_TOKEN`
2 parents 40182bd + 1864389 commit 2d8790a

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

.github/workflows/add_new_versions.yml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,10 @@ on:
55
schedule:
66
- cron: "0 0 * * 3"
77

8-
98
permissions:
109
contents: write
1110
pull-requests: write
1211

13-
1412
jobs:
1513
generate_and_raise_pr:
1614
runs-on: ubuntu-latest
@@ -34,11 +32,25 @@ jobs:
3432
python -u workflow_scripts/check-for-new-versions.py
3533
env:
3634
EXCLUDED_VERSIONS: "v20.10.x,v23.0.x,v25.0.x,v26.1.x"
35+
36+
- name: Read App Secrets
37+
uses: rancher-eio/read-vault-secrets@main
38+
with:
39+
secrets: |
40+
secret/data/github/repo/${{ github.repository }}/github/app-credentials appId | APP_ID ;
41+
secret/data/github/repo/${{ github.repository }}/github/app-credentials privateKey | PRIVATE_KEY
42+
43+
- name: Create App Token
44+
uses: actions/create-github-app-token@v1
45+
id: app-token
46+
with:
47+
app-id: ${{ env.APP_ID }}
48+
private-key: ${{ env.PRIVATE_KEY }}
3749

3850
- name: check if the PR exist
3951
if: ${{ env.PR_TITLE != '' }}
4052
env:
41-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53+
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
4254
PR_TITLE: ${{env.PR_TITLE}}
4355
run: |
4456
EXISTING_PR=$(gh pr list --limit 1500 --json title,url | jq --arg title "${PR_TITLE}" -r '.[] | select(.title==$title) | .url')
@@ -76,7 +88,7 @@ jobs:
7688
id: cpr
7789
env:
7890
SOURCE_BRANCH: ${{ steps.branch.outputs.branch }}
79-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
91+
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
8092
PR_TITLE: ${{env.PR_TITLE}}
8193
PR_BODY: autogenerated PR to add docker ${{env.NEW_VERSIONS}}
8294
run: |

0 commit comments

Comments
 (0)