Automerge New CDN Files #11
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Automerge Batches | |
on: | |
schedule: | |
- cron: '*/5 * * * *' # Run every 5 minutes | |
jobs: | |
batch-merge: | |
runs-on: ubuntu-latest | |
steps: | |
- name: List Pull Requests Ready for Merge | |
id: pr_list | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const { data: pullRequests } = await github.pulls.list({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
state: 'open', | |
sort: 'updated', | |
direction: 'desc', | |
}); | |
const prNumbers = pullRequests | |
.filter(pr => pr.labels.some(label => label.name === 'automerge')) | |
.map(pr => pr.number); | |
if (prNumbers.length > 0) { | |
return prNumbers.join(','); | |
} else { | |
return ''; | |
} | |
- name: Merge PRs | |
if: steps.pr_list.outputs.result != '' | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const prNumbers = ${{ steps.pr_list.outputs.result }}.split(','); | |
for (const pr of prNumbers) { | |
await github.pulls.merge({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
pull_number: pr, | |
merge_method: 'squash', | |
}); | |
} |