Skip to content

Commit 39609c8

Browse files
authored
Fix the GHA permission issue. (#89)
1 parent 1aa758e commit 39609c8

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

.github/workflows/update-proto-dependency.yaml

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ on:
1313
required: true
1414
default: 'main'
1515

16+
permissions:
17+
contents: write
18+
pull-requests: write
19+
id-token: write
20+
1621
jobs:
1722
update-the-dependency:
1823
runs-on: ubuntu-latest
@@ -22,23 +27,26 @@ jobs:
2227
with:
2328
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
2429
service_account: ${{ secrets.GCP_SERVICE_ACCOUNT_EMAIL }}
25-
- name: Fetch the Git Credentials
30+
- name: Get Secret Manager Secrets
2631
id: secrets
2732
uses: 'google-github-actions/get-secretmanager-secrets@v2'
2833
with:
2934
secrets: |-
30-
github_credentials:aptos-ci/GIT_CREDENTIALS
31-
- name: Setup git credentials
32-
shell: bash
35+
token:aptos-ci/github-actions-repository-dispatch
36+
- name: Configure Git user
3337
run: |
34-
git config --global credential.helper store
35-
echo "${{ steps.secrets.outputs.github_credentials }}" > ~/.git-credentials
38+
git config --global user.name "Aptos Bot"
39+
git config --global user.email "[email protected]"
3640
- name: Checkout
3741
uses: actions/checkout@v4
42+
with:
43+
token: ${{ steps.secrets.outputs.token }}
3844
- name: Setup Rust
3945
uses: actions-rust-lang/setup-rust-toolchain@v1
46+
4047
- name: Install toml
4148
run: cargo install toml-cli
49+
4250
- name: Update the dependency
4351
run: |
4452
set -e
@@ -53,25 +61,30 @@ jobs:
5361
git add Cargo.toml
5462
git commit -m "Update aptos-protos to ${{ github.event.inputs.commit_hash || github.event.client_payload.commit_hash }}"
5563
git push origin "$branch_name" --force
64+
env:
65+
GITHUB_TOKEN: ${{ steps.secrets.outputs.token }}
5666
working-directory: aptos-indexer-processors-sdk/
67+
5768
- name: Check if PR Already Exists
5869
id: check_pr
5970
run: |
60-
branch_name="${{ github.event.client_payload.branch_name }}-update-aptos-protos"
71+
branch_name="${{ github.event.inputs.branch_name || github.event.client_payload.branch_name }}-update-aptos-protos"
6172
existing_pr=$(gh pr list --base main --head "$branch_name" --json number --jq '.[].number')
6273
if [ -n "$existing_pr" ]; then
6374
echo "::set-output name=if_pr_exists::true"
6475
else
6576
echo "::set-output name=if_pr_exists::false"
6677
fi
6778
env:
68-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
79+
GITHUB_TOKEN: ${{ steps.secrets.outputs.token }}
6980
- name: Create Pull Request
7081
if: steps.check_pr.outputs.if_pr_exists == 'false'
7182
run: |
72-
branch_name="${{ github.event.client_payload.branch_name }}-update-aptos-protos"
83+
branch_name="${{ github.event.inputs.branch_name || github.event.client_payload.branch_name }}-update-aptos-protos"
7384
gh pr create --title "Update aptos-protos to upstream branch ${{ github.event.client_payload.branch_name }}" \
7485
--body "This PR updates aptos-protos to new version." \
7586
--base main \
7687
--head "$branch_name" \
7788
--label "indexer-sdk-update"
89+
env:
90+
GITHUB_TOKEN: ${{ steps.secrets.outputs.token }}

0 commit comments

Comments
 (0)