Skip to content

Commit 9cf1936

Browse files
authored
[v0.4] Fix syncing dependencies (#571)
* Fix PR not triggering CI * Fix token permission * Fix quote
1 parent e44170b commit 9cf1936

File tree

1 file changed

+28
-5
lines changed

1 file changed

+28
-5
lines changed

.github/workflows/sync-deps.yaml

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,38 @@ env:
1717
WEBHOOK_REF: "${{ github.ref_name }}"
1818

1919
permissions:
20-
contents: write
21-
pull-requests: write
20+
contents: read
21+
# Needed to access to vault
22+
id-token: write
2223

2324
jobs:
2425
sync:
2526
name: Sync dependencies
2627
runs-on: ubuntu-latest
2728
steps:
29+
- uses: rancher-eio/read-vault-secrets@main
30+
with:
31+
secrets: |
32+
secret/data/github/repo/${{ github.repository }}/github/app-credentials appId | APP_ID ;
33+
secret/data/github/repo/${{ github.repository }}/github/app-credentials privateKey | PRIVATE_KEY
34+
35+
# Fetch github token just for the webhook repository
36+
- uses: actions/create-github-app-token@v1
37+
id: app-token
38+
with:
39+
app-id: ${{ env.APP_ID }}
40+
private-key: ${{ env.PRIVATE_KEY }}
41+
repositories: |
42+
webhook
43+
2844
- name : Checkout webhook repository
2945
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
3046
with:
3147
ref: "${{ env.WEBHOOK_REF }}"
3248
path: webhook
49+
token: ${{ steps.app-token.outputs.token }}
50+
# Allow making git push request later on
51+
persist-credentials: true
3352

3453
- name : Checkout rancher repository
3554
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
@@ -44,8 +63,12 @@ jobs:
4463
- name: Configure the committer
4564
run: |
4665
cd webhook
47-
git config --global user.name "Webhook Sync Bot"
48-
git config --global user.email "[email protected]"
66+
user_id=$(gh api "/users/$APP_USER" --jq .id)
67+
git config --global user.name "$APP_USER"
68+
git config --global user.email "${user_id}+${APP_USER}@users.noreply.github.com"
69+
env:
70+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
71+
APP_USER: "${{ steps.app-token.outputs.app-slug }}[bot]"
4972

5073
- name: Run sync-deps script
5174
run: |
@@ -82,4 +105,4 @@ jobs:
82105
--head "${{ github.repository_owner }}:$BRANCH" \
83106
--base "$WEBHOOK_REF"
84107
env:
85-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
108+
GH_TOKEN: ${{ steps.app-token.outputs.token }}

0 commit comments

Comments
 (0)