Some checks are pending
Extracted from oil project — business logic removed, auth/db/deploy infrastructure generalized with APP_NAME placeholders. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
51 lines
1.7 KiB
YAML
51 lines
1.7 KiB
YAML
name: PR Preview
|
|
on:
|
|
pull_request:
|
|
types: [opened, synchronize, reopened, closed]
|
|
|
|
jobs:
|
|
test:
|
|
if: github.event.action != 'closed'
|
|
runs-on: test
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Unit tests
|
|
run: cd frontend && npm ci && npx vitest run
|
|
|
|
deploy-preview:
|
|
if: github.event.action != 'closed'
|
|
needs: test
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Deploy Preview
|
|
run: python3 scripts/deploy-preview.py deploy ${{ github.event.pull_request.number }}
|
|
- name: Comment PR
|
|
env:
|
|
GIT_TOKEN: ${{ secrets.GIT_TOKEN }}
|
|
run: |
|
|
PR_ID="${{ github.event.pull_request.number }}"
|
|
curl -sf -X POST \
|
|
"https://git.euphon.cloud/api/v1/repos/${{ github.repository }}/issues/${PR_ID}/comments" \
|
|
-H "Authorization: token ${GIT_TOKEN}" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{\"body\": \"Preview: https://pr-${PR_ID}.APP_NAME.oci.euphon.net\n\nDB is a copy of production.\"}" || true
|
|
|
|
teardown-preview:
|
|
if: github.event.action == 'closed'
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Teardown
|
|
run: python3 scripts/deploy-preview.py teardown ${{ github.event.pull_request.number }}
|
|
- name: Comment PR
|
|
env:
|
|
GIT_TOKEN: ${{ secrets.GIT_TOKEN }}
|
|
run: |
|
|
PR_ID="${{ github.event.pull_request.number }}"
|
|
curl -sf -X POST \
|
|
"https://git.euphon.cloud/api/v1/repos/${{ github.repository }}/issues/${PR_ID}/comments" \
|
|
-H "Authorization: token ${GIT_TOKEN}" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{\"body\": \"Preview torn down.\"}" || true
|