Skip to content

Auto Update PR Branches #31

Auto Update PR Branches

Auto Update PR Branches #31

name: Auto Update PR Branches
on:
schedule:
- cron: '0 */6 * * *' # every 6 hours
workflow_dispatch:
permissions:
contents: write
pull-requests: write
jobs:
update-branches:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v9
with:
script: |
const { data: prs } = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
per_page: 100,
});
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 #${pr.number}`);
} catch (e) {
console.log(`Skipped PR #${pr.number}: ${e.message}`);
}
}