forked from CopilotKit/CopilotKit
-
Notifications
You must be signed in to change notification settings - Fork 0
43 lines (39 loc) · 1.33 KB
/
Copy pathupdate-branch.yml
File metadata and controls
43 lines (39 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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@f28e40c7f34bde8b3046d885e986cb6290c5673b # 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}`);
}
}