mirror of
https://github.com/CopilotKit/CopilotKit.git
synced 2026-09-14 16:26:20 +08:00
b3db4c11b5
pull_request runs in the fork context with restricted permissions, which would block the updateBranch API call. pull_request_target runs in the base repo with full permissions — the label trigger is safe since no checkout of PR code happens here. Also treat 422 responses (already up to date, nothing to merge) as informational rather than job failures. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
44 lines
1.3 KiB
YAML
44 lines
1.3 KiB
YAML
name: Update PR branch
|
|
|
|
on:
|
|
pull_request_target:
|
|
types: [labeled]
|
|
|
|
permissions:
|
|
contents: write
|
|
pull-requests: write
|
|
|
|
jobs:
|
|
update-branch:
|
|
if: github.event.label.name == 'qa:update-branch'
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Update PR branch with base
|
|
uses: actions/github-script@v7
|
|
with:
|
|
script: |
|
|
const { owner, repo } = context.repo;
|
|
const pull_number = context.payload.pull_request.number;
|
|
|
|
try {
|
|
await github.rest.pulls.updateBranch({ owner, repo, pull_number });
|
|
core.info(`Updated branch for PR #${pull_number}`);
|
|
} catch (error) {
|
|
if (error.status === 422) {
|
|
core.info(`Branch already up to date or cannot be updated: ${error.message}`);
|
|
} else {
|
|
core.setFailed(`Failed to update branch: ${error.message}`);
|
|
}
|
|
} finally {
|
|
try {
|
|
await github.rest.issues.removeLabel({
|
|
owner,
|
|
repo,
|
|
issue_number: pull_number,
|
|
name: 'qa:update-branch',
|
|
});
|
|
} catch (error) {
|
|
core.warning(`Could not remove label: ${error.message}`);
|
|
}
|
|
}
|