Files
landing-builder/.gitea/workflows/ci.yml
T
jaybe 87866059a4
Auto PR / open-pr (push) Successful in 13s
CI / test (pull_request) Successful in 52s
chore(ci): auto-merge 단계에 'automerge' 라벨 가드 확정 반영
2025-11-14 21:52:06 +09:00

73 lines
2.3 KiB
YAML

name: CI
on:
push:
branches: [ main, master ]
pull_request:
jobs:
test:
runs-on: [macos, host]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install deps
run: npm ci
- name: Unit/Component tests (Vitest)
run: npm test
env:
CI: true
- name: Install Playwright browsers
run: npx playwright install --with-deps
- name: E2E tests (Playwright)
run: npm run test:e2e -- --reporter=line
env:
CI: true
- name: Upload Playwright report
if: always()
uses: actions/upload-artifact@v4
with:
name: playwright-report
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 "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}")
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"