-
Notifications
You must be signed in to change notification settings - Fork 169
41 lines (36 loc) · 1.08 KB
/
auto-merge-readme.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
name: Auto Merge README Changes
on:
pull_request_target:
types: [opened, synchronize, reopened]
paths:
- 'README.md'
permissions:
contents: write
pull-requests: write
issues: write
actions: write
jobs:
auto-merge:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Check if PR only modifies README.md
id: check_files
run: |
base_sha="${{ github.event.pull_request.base.sha }}"
head_sha="${{ github.event.pull_request.head.sha }}"
files_changed=$(git diff --name-only $base_sha $head_sha)
if [ "$files_changed" == "README.md" ]; then
echo "only_readme=true" >> $GITHUB_OUTPUT
else
echo "only_readme=false" >> $GITHUB_OUTPUT
fi
- name: Auto-merge PR
if: steps.check_files.outputs.only_readme == 'true'
run: |
gh pr merge --auto --merge "${{ github.event.pull_request.number }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}