Update auto-merge.yaml #4
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: Auto-merge Entries PRs | |
on: | |
pull_request: | |
types: | |
- opened | |
- synchronize | |
jobs: | |
auto-merge: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository content | |
uses: ./github/workflows | |
- 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: akshithere/PokeArcadia | |
with: | |
merge-method: merge | |
commit-message: "Automatically merging PR that only adds new files to /backend/Entries" | |
github-token: ${{ secrets.GITHUB_TOKEN }} |