ci: auto-merge PR on validation pass
Some checks failed
Deploy Nexus / deploy (push) Has been cancelled

Replaces polling merge-bot with event-driven CI.
When all checks pass, the workflow squash-merges automatically.
This commit is contained in:
Alexander Whitestone
2026-03-24 00:09:04 -04:00
parent 440e31e36f
commit 5dd486e9b8

View File

@@ -14,15 +14,12 @@ jobs:
- name: Validate HTML
run: |
# Check index.html exists and is valid-ish
test -f index.html || { echo "ERROR: index.html missing"; exit 1; }
# Check for unclosed tags (basic)
python3 -c "
import html.parser, sys
class V(html.parser.HTMLParser):
def __init__(self):
super().__init__()
self.errors = []
def handle_starttag(self, tag, attrs): pass
def handle_endtag(self, tag): pass
v = V()
@@ -36,7 +33,6 @@ jobs:
- name: Validate JavaScript
run: |
# Syntax check all JS files
FAIL=0
for f in $(find . -name '*.js' -not -path './node_modules/*' -not -name 'sw.js'); do
if ! node --check "$f" 2>/dev/null; then
@@ -50,7 +46,6 @@ jobs:
- name: Validate JSON
run: |
# Check all JSON files parse
FAIL=0
for f in $(find . -name '*.json' -not -path './node_modules/*'); do
if ! python3 -c "import json; json.load(open('$f'))"; then
@@ -64,7 +59,6 @@ jobs:
- name: Check file size budget
run: |
# Performance budget: no single JS file > 500KB
FAIL=0
for f in $(find . -name '*.js' -not -path './node_modules/*'); do
SIZE=$(wc -c < "$f")
@@ -76,3 +70,35 @@ jobs:
fi
done
exit $FAIL
auto-merge:
needs: validate
runs-on: ubuntu-latest
steps:
- name: Merge PR
env:
GITEA_TOKEN: ${{ secrets.MERGE_TOKEN }}
run: |
PR_NUM=$(echo "${{ github.event.pull_request.number }}")
REPO="${{ github.repository }}"
API="http://143.198.27.163:3000/api/v1"
echo "CI passed. Auto-merging PR #${PR_NUM}..."
# Squash merge
RESULT=$(curl -s -w "\n%{http_code}" -X POST \
-H "Authorization: token ${GITEA_TOKEN}" \
-H "Content-Type: application/json" \
-d '{"Do":"squash","delete_branch_after_merge":true}' \
"${API}/repos/${REPO}/pulls/${PR_NUM}/merge")
HTTP_CODE=$(echo "$RESULT" | tail -1)
BODY=$(echo "$RESULT" | head -n -1)
if [ "$HTTP_CODE" = "200" ] || [ "$HTTP_CODE" = "405" ]; then
echo "Merged successfully (or already merged)"
else
echo "Merge failed: HTTP ${HTTP_CODE}"
echo "$BODY"
# Don't fail the job — PR stays open for manual review
fi