Skip to content

Added Images

Added Images #9

Workflow file for this run

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@v3
with:
fetch-depth: 0 # Ensures all branches are fetched
- name: Fetch all branches
run: git fetch --all
- 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 origin/main...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: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { context, github } = require('@actions/github');
await github.pulls.merge({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number,
merge_method: "merge",
});