Deploy Snaplet preview databases filled with production-accurate data in no time.
With this action, you can finally enjoy fully isolated and stateful preview environments. Get a new preview database filled with production-accurate data anytime you need it and plug it into your Jamstack hosting platform of choice like Vercel.
By default, the preview database will be populated with data from your latest Snaplet snapshot.
Learn more about creating snapshots in our docs.
Create a GitHub Action Workflow file in your repository following one of these examples.
# .github/workflows/preview.ymlname: Preview Environmentenv:
SNAPLET_ACCESS_TOKEN: ${{ secrets.SNAPLET_ACCESS_TOKEN }}SNAPLET_PROJECT_ID: <YOUR_SNAPLET_PROJECT_ID>on:
pull_request:
types: [opened, synchronize, closed]branches:
- mainjobs:
deploy:
if: ${{ github.event.action == 'opened' || github.event.action == 'synchronize' }}runs-on: ubuntu-lateststeps:
- id: snapletuses: snaplet/action@v1
- run: echo ${{ steps.snaplet.outputs.database-url }}delete:
if: ${{ github.event.action == 'closed' }}runs-on: ubuntu-lateststeps:
- uses: snaplet/action@v1with:
delete: trueUsing snaplet/vercel-action
# .github/workflows/preview.ymlname: Preview Environmentenv:
SNAPLET_ACCESS_TOKEN: ${{ secrets.SNAPLET_ACCESS_TOKEN }}SNAPLET_PROJECT_ID: <YOUR_SNAPLET_PROJECT_ID>VERCEL_ACCESS_TOKEN: ${{ secrets.VERCEL_ACCESS_TOKEN }}VERCEL_PROJECT_ID: <YOUR_VERCEL_PROJECT_ID>on:
pull_request:
types: [opened, synchronize, closed]branches:
- mainjobs:
deploy:
if: ${{ github.event.action == 'opened' || github.event.action == 'synchronize' }}runs-on: ubuntu-lateststeps:
- id: snapletuses: snaplet/action@v1
- uses: snaplet/vercel-action@v1with:
env: | DATABASE_URL=${{ steps.snaplet.outputs.database-url }}delete:
if: ${{ github.event.action == 'closed' }}runs-on: ubuntu-lateststeps:
- uses: snaplet/action@v1with:
delete: true
- uses: snaplet/vercel-action@v1with:
delete: true- SNAPLET_ACCESS_TOKEN
- SNAPLET_PROJECT_ID
database-create-command:
description: Command used to generate the instant databaserequired: falsetype: stringdefault: snaplet preview-database create --git --latestdatabase-delete-command:
description: Command used to delete the instant databaserequired: falsetype: stringdefault: snaplet preview-database drop --gitdatabase-url-command:
description: Command used to get the instant database urlrequired: falsetype: stringdefault: snaplet preview-database url --gitdelete:
description: Delete the databaserequired: falsetype: booleandefault: falsereset:
description: Reset the database state on each commitrequired: falsetype: booleandefault: falsedatabase-url:
description: Instant database url