auto: PR for feat/ci-automerge-guard #11
+12
-2
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user