mirror of
https://github.com/tiennm99/is-a-dev.git
synced 2026-10-13 02:14:43 +00:00
Add GitHub Action to update PR branches on push
This commit is contained in:
1 parent
4de04f4e27
commit
aa560a59e9
1 file changed
+41
@@ -0,0 +1,41 @@
|
||||
name: Update PR Branches
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
|
||||
jobs:
|
||||
update:
|
||||
name: Update
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Update branches
|
||||
uses: actions/github-script@v8
|
||||
with:
|
||||
github-token: ${{ secrets.BOT }}
|
||||
script: |
|
||||
const { data: prs } = await github.rest.pulls.list({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
state: "open"
|
||||
});
|
||||
|
||||
for (const pr of prs) {
|
||||
try {
|
||||
await github.rest.pulls.updateBranch({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
pull_number: pr.number
|
||||
});
|
||||
|
||||
console.log(`Updated #${pr.number} (${pr.head.ref})`);
|
||||
} catch (error) {
|
||||
console.log(`Could not update #${pr.number}: ${error.message}`);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user