Skip to content

Commit c32a29f

Browse files
authored
chore(workflow): automerge clean pull request
1 parent 3ec0fee commit c32a29f

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Merge Active All-Contributors PRs
2+
3+
on:
4+
schedule:
5+
- cron: '0 */6 * * *'
6+
workflow_dispatch:
7+
8+
jobs:
9+
merge-active-prs:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
pull-requests: write
14+
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v3
18+
19+
- name: Merge active PRs
20+
uses: actions/github-script@v6
21+
with:
22+
github-token: ${{ secrets.GITHUB_TOKEN }}
23+
script: |
24+
const { data: pullRequests } = await github.rest.pulls.list({
25+
owner: context.repo.owner,
26+
repo: context.repo.repo,
27+
state: 'open',
28+
sort: 'created',
29+
direction: 'asc'
30+
});
31+
32+
for (const pr of pullRequests) {
33+
if (pr.user.login === 'allcontributors[bot]' && pr.mergeable_state === 'clean') {
34+
try {
35+
await github.rest.pulls.merge({
36+
owner: context.repo.owner,
37+
repo: context.repo.repo,
38+
pull_number: pr.number,
39+
merge_method: 'squash'
40+
});
41+
console.log(`Successfully merged PR #${pr.number}`);
42+
} catch (error) {
43+
console.error(`Failed to merge PR #${pr.number}: ${error.message}`);
44+
}
45+
}
46+
}

0 commit comments

Comments
 (0)