Skip to content
This repository was archived by the owner on Sep 19, 2024. It is now read-only.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

24 Commits

Repository files navigation

Snaplet Preview Databases Github Action

Snappy's paw makes a database appear by snapping their fingers with the title 'SNAP!'

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.

Usage

Create a GitHub Action Workflow file in your repository following one of these examples.

Standalone

# .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: true

With Vercel

Using 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

Documentation

Environment variables

  • SNAPLET_ACCESS_TOKEN
  • SNAPLET_PROJECT_ID

Inputs

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: false

Outputs

database-url:
description: Instant database url

About

⚡ Snaplet Instant Database Github Action

Topics

Resources

Stars

15 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors