Skip to content

Commit 9dca4d4

Browse files
committed
fix(ci): use PAT for cross-repository access and add actions permission
- Switch from GITHUB_TOKEN to CLOUDBASE_EXAMPLES_TOKEN (PAT) for accessing awsome-cloudbase-examples - Add actions: write permission to support artifact uploads - Update CONTRIBUTING.md with PAT configuration instructions - Configure git remote URL with PAT token for authentication
1 parent ab72e04 commit 9dca4d4

3 files changed

Lines changed: 11 additions & 1 deletion

File tree

.github/workflows/build-zips.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ jobs:
2525
runs-on: ubuntu-latest
2626
permissions:
2727
contents: write
28+
actions: write
2829
steps:
2930
- name: Checkout current repo
3031
uses: actions/checkout@v4
@@ -37,6 +38,7 @@ jobs:
3738
repository: TencentCloudBase/awsome-cloudbase-examples
3839
ref: ${{ github.event.inputs.target_branch || 'master' }}
3940
path: cloudbase-examples
41+
token: ${{ secrets.CLOUDBASE_EXAMPLES_TOKEN }}
4042

4143
- name: Setup Node.js
4244
uses: actions/setup-node@v4
@@ -82,6 +84,8 @@ jobs:
8284
- name: Commit and push changes
8385
if: github.event.inputs.commit_changes == 'true'
8486
working-directory: cloudbase-examples
87+
env:
88+
PAT_TOKEN: ${{ secrets.CLOUDBASE_EXAMPLES_TOKEN }}
8589
run: |
8690
git config user.name "github-actions[bot]"
8791
git config user.email "github-actions[bot]@users.noreply.github.com"
@@ -90,5 +94,6 @@ jobs:
9094
echo "No changes to commit, skipping commit and push"
9195
else
9296
git commit -m "chore: sync config from ${{ github.event.inputs.source_branch || 'main' }}"
97+
git remote set-url origin https://x-access-token:${PAT_TOKEN}@github.com/TencentCloudBase/awsome-cloudbase-examples.git
9398
git push origin ${{ github.event.inputs.target_branch || 'master' }}
9499
fi

.github/workflows/sync-branch.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ jobs:
3131
repository: TencentCloudBase/awsome-cloudbase-examples
3232
ref: ${{ github.event.inputs.target_branch }}
3333
path: cloudbase-examples
34+
token: ${{ secrets.CLOUDBASE_EXAMPLES_TOKEN }}
3435

3536
- name: Setup Node.js
3637
uses: actions/setup-node@v4
@@ -61,6 +62,8 @@ jobs:
6162
- name: Commit and push changes
6263
if: github.event.inputs.commit_changes == 'true'
6364
working-directory: cloudbase-examples
65+
env:
66+
PAT_TOKEN: ${{ secrets.CLOUDBASE_EXAMPLES_TOKEN }}
6467
run: |
6568
git config user.name "github-actions[bot]"
6669
git config user.email "github-actions[bot]@users.noreply.github.com"
@@ -69,5 +72,6 @@ jobs:
6972
echo "No changes to commit, skipping commit and push"
7073
else
7174
git commit -m "chore: sync config from ${{ github.event.inputs.source_branch }}"
75+
git remote set-url origin https://x-access-token:${PAT_TOKEN}@github.com/TencentCloudBase/awsome-cloudbase-examples.git
7276
git push origin ${{ github.event.inputs.target_branch }}
7377
fi

CONTRIBUTING.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,8 +331,9 @@ const ideRulesConfigs = [
331331
5. 点击 "Run workflow" 按钮
332332

333333
**注意事项**
334-
- 由于两个仓库在同一组织下,使用默认的 `GITHUB_TOKEN` 即可访问
334+
- 需要配置 `CLOUDBASE_EXAMPLES_TOKEN` secret(Personal Access Token)用于访问 cloudbase-examples 仓库
335335
- 如果目标分支不存在,workflow 会自动创建
336+
- 创建 PAT 时需要勾选 `repo` 权限
336337

337338
## 行为准则
338339

0 commit comments

Comments
 (0)