From 91dd9b161a438d763d248a063ba3f9153a62a79d Mon Sep 17 00:00:00 2001 From: Jaybe Date: Fri, 14 Nov 2025 21:26:55 +0900 Subject: [PATCH] =?UTF-8?q?chore(ci):=20auto-merge=20=EC=95=88=EC=A0=84?= =?UTF-8?q?=EC=9E=A5=EC=B9=98=20=EC=B6=94=EA=B0=80=20=E2=80=94=20'automerg?= =?UTF-8?q?e'=20=EB=9D=BC=EB=B2=A8=EC=9D=B4=20=EC=9E=88=EC=9D=84=20?= =?UTF-8?q?=EB=95=8C=EB=A7=8C=20=EB=A8=B8=EC=A7=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/ci.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 59f7af2..1eed860 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -34,6 +34,35 @@ jobs: env: CI: true + - name: Auto-merge PR on green + if: ${{ github.event_name == 'pull_request' }} + env: + CI_TOKEN: ${{ secrets.CI_TOKEN }} + GITEA_BASE_URL: https://gitea.jaybe.dev + PR_NUMBER: ${{ github.event.pull_request.number }} + REPO: ${{ github.repository }} + run: | + set -euo pipefail + if [ -z "${CI_TOKEN:-}" ]; then + echo "CI_TOKEN not set; skipping auto-merge"; exit 0; fi + OWNER=$(echo "$REPO" | cut -d'/' -f1) + NAME=$(echo "$REPO" | cut -d'/' -f2) + echo "Checking labels for PR #$PR_NUMBER on $OWNER/$NAME" + LABELS_JSON=$(curl -sS -X GET \ + -H "Authorization: token ${CI_TOKEN}" \ + "${GITEA_BASE_URL}/api/v1/repos/${OWNER}/${NAME}/issues/${PR_NUMBER}") + echo "Labels payload: $LABELS_JSON" | sed 's/.\{200\}$/.../' + if ! echo "$LABELS_JSON" | grep -qi '"name":"automerge"'; then + echo "Label 'automerge' not present; skipping merge"; exit 0; fi + echo "Label 'automerge' present; proceeding to merge" + echo "Merging PR #$PR_NUMBER for $OWNER/$NAME" + RESP=$(curl -sS -X POST \ + -H "Content-Type: application/json" \ + -H "Authorization: token ${CI_TOKEN}" \ + "${GITEA_BASE_URL}/api/v1/repos/${OWNER}/${NAME}/pulls/${PR_NUMBER}/merge" \ + -d '{"Do":"merge","MergeMessage":"auto-merge: CI green"}' || true) + echo "API response: $RESP" + - name: Upload Playwright report if: always() uses: actions/upload-artifact@v4