Skip to content

Commit 0f4a53c

Browse files
authored
Add auto-merge workflow for specific file changes
1 parent a2f03c7 commit 0f4a53c

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Auto Merge Specific File
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened, ready_for_review]
6+
7+
jobs:
8+
auto-merge:
9+
runs-on: ubuntu-latest
10+
if: github.event.pull_request.draft == false
11+
steps:
12+
- name: Check changed files
13+
id: file-check
14+
uses: tj-actions/changed-files@v44
15+
with:
16+
files: path/to/your/specific-file.md
17+
18+
- name: Get PR info
19+
id: pr-info
20+
uses: actions/github-script@v7
21+
with:
22+
script: |
23+
const { data: pr } = await github.rest.pulls.get({
24+
owner: context.repo.owner,
25+
repo: context.repo.repo,
26+
pull_number: context.payload.pull_request.number
27+
});
28+
return pr.mergeable_state;
29+
30+
- name: Auto-merge PR if only the specific file changed and no conflicts
31+
if: steps.file-check.outputs.only_changed == 'true' && steps.pr-info.outputs.result == 'clean'
32+
uses: actions/github-script@v7
33+
with:
34+
script: |
35+
github.rest.pulls.merge({
36+
owner: context.repo.owner,
37+
repo: context.repo.repo,
38+
pull_number: context.payload.pull_request.number
39+
})

0 commit comments

Comments
 (0)