diff --git a/.github/workflows/db-preview.yml b/.github/workflows/db-preview.yml new file mode 100644 index 0000000000..6604523f4c --- /dev/null +++ b/.github/workflows/db-preview.yml @@ -0,0 +1,37 @@ +# .github/workflows/preview.yml + +name: Preview Environment + +env: + SNAPLET_ACCESS_TOKEN: ${{ secrets.SNAPLET_ACCESS_TOKEN }} + SNAPLET_PROJECT_ID: ${{ secrets.SNAPLET_PROJECT_ID }} + VERCEL_ACCESS_TOKEN: ${{ secrets.VERCEL_ACCESS_TOKEN }} + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} + +on: + pull_request: + types: [opened, synchronize, closed] + branches: + - main + +jobs: + db-preview-deploy: + if: ${{ github.event.action == 'opened' || github.event.action == 'synchronize' }} + runs-on: ubuntu-latest + steps: + - id: snaplet + uses: snaplet/action@v1 + - uses: snaplet/vercel-action@v1 + with: + env: | + DATABASE_URL=${{ steps.snaplet.outputs.database-url }} + db-preview-delete: + if: ${{ github.event.action == 'closed' }} + runs-on: ubuntu-latest + steps: + - uses: snaplet/action@v1 + with: + delete: true + - uses: snaplet/vercel-action@v1 + with: + delete: true