Skip to content

Commit 45084b8

Browse files
authored
fix: update create-pull-request action to fix token permission error
Replace fish9167/create-pull-request@v3 with peter-evans/create-pull-request@v6 which supports separate tokens for git push and PR creation API calls. - Add job-level permissions (contents: write, pull-requests: write) so GITHUB_TOKEN has the pull-requests: write scope needed to create PRs - Use token: GITHUB_TOKEN for the PR creation API call (which requires pull-requests: write permission on cocos/cocos4) - Use git-token: PR_TOKEN for git push operations to the fork (cocos-robot/cocos4), where PR_TOKEN already works Previously, fish9167/create-pull-request@v3 used a single PR_TOKEN for both git push and GitHub API calls. PR_TOKEN can push to the fork but lacks pull-requests: write on cocos/cocos4, causing: 'Resource not accessible by personal access token'
1 parent ac8a50f commit 45084b8

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

.github/workflows/native-bindings.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ jobs:
1111
matrix:
1212
node-version: [18.x]
1313
runs-on: ubuntu-latest
14+
permissions:
15+
contents: write
16+
pull-requests: write
1417
steps:
1518
- uses: actions/checkout@v4
1619
- name: Install CMake & Clang Tidy
@@ -55,7 +58,7 @@ jobs:
5558
node ./cmake/scripts/engine-version.js
5659
5760
- name: Create Pull Request
58-
uses: fish9167/create-pull-request@v3
61+
uses: peter-evans/create-pull-request@v6
5962
if: github.event_name == 'pull_request_target' && github.event.action == 'closed' && github.event.pull_request.merged == true
6063
with:
6164
title: '[ci skip][AUTO]: Automated PR to generate code'
@@ -65,7 +68,8 @@ jobs:
6568
committer: cocos-robot <cocos-robot@cocos.com>
6669
author: cocos-robot <cocos-robot@cocos.com>
6770
commit-message: "[ci skip][AUTO]: Automated code generating update: ${{ github.event.pull_request.head.sha }} (#${{ github.event.number }})"
68-
token: ${{ secrets.PR_TOKEN }}
71+
token: ${{ secrets.GITHUB_TOKEN }}
72+
git-token: ${{ secrets.PR_TOKEN }}
6973
push-to-fork: cocos-robot/cocos4
7074
branch: t/bot/genbindings
7175
branch-suffix: short-commit-hash

0 commit comments

Comments
 (0)