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.\"}"