test
Auto PR / open-pr (push) Successful in 17s
Auto Label PR / add-automerge-label (pull_request) Successful in 3s
CI / test (pull_request) Successful in 51s

This commit is contained in:
2025-11-14 22:05:38 +09:00
parent b24bfb4af6
commit a633fe0a54
+12 -2
View File
@@ -60,13 +60,23 @@ jobs:
LABELS_JSON=$(curl -sS -X GET \ LABELS_JSON=$(curl -sS -X GET \
-H "Authorization: token ${CI_TOKEN}" \ -H "Authorization: token ${CI_TOKEN}" \
"${GITEA_BASE_URL}/api/v1/repos/${OWNER}/${NAME}/issues/${PR_NUMBER}") "${GITEA_BASE_URL}/api/v1/repos/${OWNER}/${NAME}/issues/${PR_NUMBER}")
echo "labels payload (first 200 chars):"; echo "$LABELS_JSON" | cut -c1-200 || true
if ! echo "$LABELS_JSON" | grep -qi '"name":"automerge"'; then if ! echo "$LABELS_JSON" | grep -qi '"name":"automerge"'; then
echo "Label 'automerge' not present; skipping merge"; exit 0; fi echo "Label 'automerge' not present; skipping merge"; exit 0; fi
echo "Label 'automerge' present; proceeding to merge" echo "Label 'automerge' present; proceeding to merge"
# ensure PR is open
PR_JSON=$(curl -sS -X GET \
-H "Authorization: token ${CI_TOKEN}" \
"${GITEA_BASE_URL}/api/v1/repos/${OWNER}/${NAME}/pulls/${PR_NUMBER}")
STATE=$(echo "$PR_JSON" | sed -n 's/.*"state":"\([^"]*\)".*/\1/p')
echo "PR state: ${STATE:-unknown}"
if [ "${STATE:-}" != "open" ]; then
echo "PR state is not open; skipping merge"; exit 0; fi
echo "Merging PR #$PR_NUMBER for $OWNER/$NAME" echo "Merging PR #$PR_NUMBER for $OWNER/$NAME"
RESP=$(curl -sS -X POST \ HTTP_CODE=$(curl -sS -o /tmp/merge_resp.json -w "%{http_code}" -X POST \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-H "Authorization: token ${CI_TOKEN}" \ -H "Authorization: token ${CI_TOKEN}" \
"${GITEA_BASE_URL}/api/v1/repos/${OWNER}/${NAME}/pulls/${PR_NUMBER}/merge" \ "${GITEA_BASE_URL}/api/v1/repos/${OWNER}/${NAME}/pulls/${PR_NUMBER}/merge" \
-d '{"Do":"merge","MergeMessage":"auto-merge: CI green"}' || true) -d '{"Do":"merge","MergeMessage":"auto-merge: CI green"}' || true)
echo "API response: $RESP" echo "merge http: $HTTP_CODE"
echo "merge resp:"; cat /tmp/merge_resp.json || true