From 86a2c1049a54527d427add6f2cbf385a5271c025 Mon Sep 17 00:00:00 2001 From: Jaybe Date: Fri, 14 Nov 2025 21:22:00 +0900 Subject: [PATCH] =?UTF-8?q?chore(ci):=20=EC=9E=90=EB=8F=99=20PR/=EA=B7=B8?= =?UTF-8?q?=EB=A6=B0=EC=8B=9C=20=EC=9E=90=EB=8F=99=20=EB=A8=B8=EC=A7=80=20?= =?UTF-8?q?=EA=B5=AC=EC=84=B1(CI=5FTOKEN=20=EC=82=AC=EC=9A=A9)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/auto-pr.yml | 38 ++++++++++++++++++++++++++++++++++++ .gitea/workflows/ci.yml | 21 ++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 .gitea/workflows/auto-pr.yml diff --git a/.gitea/workflows/auto-pr.yml b/.gitea/workflows/auto-pr.yml new file mode 100644 index 0000000..cdd89b5 --- /dev/null +++ b/.gitea/workflows/auto-pr.yml @@ -0,0 +1,38 @@ +name: Auto PR + +on: + push: + branches: + - 'feat/**' + +jobs: + open-pr: + runs-on: [macos, host] + steps: + - name: Create Pull Request via Gitea API + env: + CI_TOKEN: ${{ secrets.CI_TOKEN }} + GITEA_BASE_URL: https://gitea.jaybe.dev + REPO: ${{ github.repository }} + HEAD_BRANCH: ${{ github.ref_name }} + BASE_BRANCH: main + run: | + set -euo pipefail + if [ -z "${CI_TOKEN:-}" ]; then + echo "GITEA_TOKEN not set; skipping auto-pr"; exit 0; fi + OWNER=$(echo "$REPO" | cut -d'/' -f1) + NAME=$(echo "$REPO" | cut -d'/' -f2) + TITLE="auto: PR for $HEAD_BRANCH" + BODY="Automated PR created on push to $HEAD_BRANCH" + echo "Creating PR $HEAD_BRANCH -> $BASE_BRANCH for $OWNER/$NAME" + HTTP_CODE=$(curl -sS -o /tmp/pr_resp.json -w "%{http_code}" -X POST \ + -H "Content-Type: application/json" \ + -H "Authorization: token ${CI_TOKEN}" \ + "${GITEA_BASE_URL}/api/v1/repos/${OWNER}/${NAME}/pulls" \ + -d "{\"head\":\"${HEAD_BRANCH}\",\"base\":\"${BASE_BRANCH}\",\"title\":\"${TITLE}\",\"body\":\"${BODY}\"}") || true + echo "API status: $HTTP_CODE" + if [ "$HTTP_CODE" = "201" ]; then + echo "PR created"; cat /tmp/pr_resp.json + else + echo "PR not created (possibly exists). Response:"; cat /tmp/pr_resp.json || true + fi diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 59f7af2..4f5e814 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -42,3 +42,24 @@ jobs: path: playwright-report if-no-files-found: ignore retention-days: 3 + + - 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 "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" -- 2.52.0