claude-home/.gitea/workflows/auto-merge-docs.yml
Cal Corum bc99bcdf4d
All checks were successful
Auto-merge docs-only PRs / auto-merge-docs (pull_request) Successful in 2s
ci: remove approval step from auto-merge workflow
Approval fails with "approve your own pull is not allowed" since
the token belongs to the repo owner. Merge works without it.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-18 23:42:36 -05:00

56 lines
1.7 KiB
YAML

name: Auto-merge docs-only PRs
on:
pull_request:
branches: [main]
types: [opened, synchronize]
jobs:
auto-merge-docs:
runs-on: ubuntu-latest
steps:
- name: Check if all changes are markdown
id: check
env:
GITEA_TOKEN: ${{ secrets.AUTO_MERGE_TOKEN }}
run: |
PR_NUMBER=${{ github.event.pull_request.number }}
API_URL="${{ github.server_url }}/api/v1/repos/${{ github.repository }}/pulls/${PR_NUMBER}/files"
FILES=$(curl -sf -H "Authorization: token ${GITEA_TOKEN}" "${API_URL}" | jq -r '.[].filename')
if [ -z "$FILES" ]; then
echo "No files found in PR"
echo "docs_only=false" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "Changed files:"
echo "$FILES"
DOCS_ONLY=true
while IFS= read -r file; do
if [[ ! "$file" =~ \.md$ ]]; then
echo "Non-markdown file found: $file"
DOCS_ONLY=false
break
fi
done <<< "$FILES"
echo "docs_only=${DOCS_ONLY}" >> "$GITHUB_OUTPUT"
- name: Auto-merge
if: steps.check.outputs.docs_only == 'true'
env:
GITEA_TOKEN: ${{ secrets.AUTO_MERGE_TOKEN }}
run: |
PR_NUMBER=${{ github.event.pull_request.number }}
API_BASE="${{ github.server_url }}/api/v1/repos/${{ github.repository }}/pulls/${PR_NUMBER}"
curl -sf -X POST "${API_BASE}/merge" \
-H "Authorization: token ${GITEA_TOKEN}" \
-H "Content-Type: application/json" \
-d '{"Do": "merge", "merge_message_field": "Auto-merge: docs-only PR #'"${PR_NUMBER}"'"}'
echo "PR #${PR_NUMBER} auto-merged."