|
17 | 17 | WEBHOOK_REF: "${{ github.ref_name }}"
|
18 | 18 |
|
19 | 19 | permissions:
|
20 |
| - contents: write |
21 |
| - pull-requests: write |
| 20 | + contents: read |
| 21 | + # Needed to access to vault |
| 22 | + id-token: write |
22 | 23 |
|
23 | 24 | jobs:
|
24 | 25 | sync:
|
25 | 26 | name: Sync dependencies
|
26 | 27 | runs-on: ubuntu-latest
|
27 | 28 | 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 | +
|
28 | 44 | - name : Checkout webhook repository
|
29 | 45 | uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
30 | 46 | with:
|
31 | 47 | ref: "${{ env.WEBHOOK_REF }}"
|
32 | 48 | path: webhook
|
| 49 | + token: ${{ steps.app-token.outputs.token }} |
| 50 | + # Allow making git push request later on |
| 51 | + persist-credentials: true |
33 | 52 |
|
34 | 53 | - name : Checkout rancher repository
|
35 | 54 | uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
|
44 | 63 | - name: Configure the committer
|
45 | 64 | run: |
|
46 | 65 | 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]" |
49 | 72 |
|
50 | 73 | - name: Run sync-deps script
|
51 | 74 | run: |
|
|
82 | 105 | --head "${{ github.repository_owner }}:$BRANCH" \
|
83 | 106 | --base "$WEBHOOK_REF"
|
84 | 107 | env:
|
85 |
| - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 108 | + GH_TOKEN: ${{ steps.app-token.outputs.token }} |
0 commit comments