diff --git a/.github/workflow/auto-pr-merge.yml b/.github/workflow/auto-pr-merge.yml deleted file mode 100644 index 8b13789..0000000 --- a/.github/workflow/auto-pr-merge.yml +++ /dev/null @@ -1 +0,0 @@ - diff --git a/.github/workflows/auto-pr-merge.yml b/.github/workflows/auto-pr-merge.yml new file mode 100644 index 0000000..197e4f5 --- /dev/null +++ b/.github/workflows/auto-pr-merge.yml @@ -0,0 +1,36 @@ +name: Auto Merge Contributor PRs + +on: + pull_request: + types: [opened, synchronize, reopened] + +permissions: + contents: write + pull-requests: write + +jobs: + auto-merge: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Check only Contributors.md was modified + id: check-files + run: | + CHANGED=$(git diff --name-only origin/${{ github.base_ref }}...HEAD) + echo "Changed files: $CHANGED" + if [ "$CHANGED" = "Contributors.md" ]; then + echo "valid=true" >> $GITHUB_OUTPUT + else + echo "valid=false" >> $GITHUB_OUTPUT + echo "PR modifies files other than Contributors.md — skipping auto-merge." + fi + + - name: Auto-merge PR + if: steps.check-files.outputs.valid == 'true' + run: gh pr merge --squash "${{ github.event.pull_request.number }}" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}