-
Notifications
You must be signed in to change notification settings - Fork 7
47 lines (38 loc) · 1.4 KB
/
auto-merge.yaml
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
42
43
44
45
46
47
name: Auto-merge Entries PRs
on:
pull_request:
types:
- opened
- synchronize
jobs:
auto-merge:
runs-on: ubuntu-latest
steps:
- name: Checkout repository content
uses: actions/checkout@v2
- name: Check if only new files are added to /backend/Entries
id: check-changes
run: |
# Get the list of changed files in the PR
changed_files=$(git diff --name-status HEAD~1 HEAD)
# Initialize flags
new_files_only=true
# Iterate over changed files
while IFS= read -r line; do
status=$(echo $line | cut -f1)
file=$(echo $line | cut -f2)
# Check if the file is not in the /backend/Entries folder or if it is not new
if [[ "$file" != backend/Entries/* ]] || [[ "$status" != "A" ]]; then
new_files_only=false
break
fi
done <<< "$changed_files"
# Set the output based on whether only new files were added
echo "::set-output name=new_files_only::$new_files_only"
- name: Merge pull request
if: steps.check-changes.outputs.new_files_only == 'true'
uses: peter-evans/merge-pull-request@v3
with:
merge-method: merge
commit-message: "Automatically merging PR that only adds new files to /backend/Entries"
github-token: ${{ secrets.GITHUB_TOKEN }}