Files
oil-formula-calculator/.gitea/workflows/preview.yml
Hera Zhao 2ee0c7c241
Some checks failed
Test / test (push) Successful in 5s
PR Preview / deploy-preview (pull_request) Failing after 6s
PR Preview / teardown-preview (pull_request) Has been skipped
Rewrite preview deploy as Python script
- scripts/deploy-preview.py: deploy/teardown PR preview environments
  - rsync source to oci, copy prod DB, build image, apply K8s manifests
  - No PVC, DB baked into image
- Simplified preview.yml workflow to call the Python script
- Remove old shell deploy scripts

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 21:10:29 +00:00

48 lines
1.6 KiB
YAML

name: PR Preview
on:
pull_request:
types: [opened, synchronize, reopened, closed]
env:
BASE_DOMAIN: oil.oci.euphon.net
jobs:
deploy-preview:
if: github.event.action != 'closed'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Unit tests
run: cd frontend && npm ci && npm run test:unit
- name: Deploy Preview
run: python3 scripts/deploy-preview.py deploy ${{ github.event.pull_request.number }}
- name: Comment PR
run: |
PR_ID="${{ github.event.pull_request.number }}"
curl -s -X POST \
"https://git.euphon.cloud/api/v1/repos/${{ github.repository }}/issues/${PR_ID}/comments" \
-H "Authorization: token ${{ secrets.GIT_TOKEN }}" \
-H "Content-Type: application/json" \
-d "{\"body\": \"🚀 **Preview deployed**: https://pr-${PR_ID}.${BASE_DOMAIN}\n\nDB is a copy of production. Changes won't affect prod.\"}"
teardown-preview:
if: github.event.action == 'closed'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Teardown Preview
run: python3 scripts/deploy-preview.py teardown ${{ github.event.pull_request.number }}
- name: Comment PR
run: |
PR_ID="${{ github.event.pull_request.number }}"
curl -s -X POST \
"https://git.euphon.cloud/api/v1/repos/${{ github.repository }}/issues/${PR_ID}/comments" \
-H "Authorization: token ${{ secrets.GIT_TOKEN }}" \
-H "Content-Type: application/json" \
-d "{\"body\": \"🗑️ Preview environment torn down.\"}"