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

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
avallete committed Apr 25, 2023
0 parents commit 9c4618b
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 0 deletions.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
## Usage:

```yml
name: Preview Environment

env:
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:
- main

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- id: snaplet
uses: snaplet/vercel-snaplet@v1
```
78 changes: 78 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Vercel Snaplet Deployments

author: Snaplet

description: Use snaplet and vercel deployments to create a preview database for your vercel deployment.

inputs:
# Mixed action inputs
delete:
description: Delete the preview on vercel and the instant database related to it
required: false
type: boolean
default: ${{ github.event.action == 'closed' }}
# Vercel action inputs
vercel-await-for-deployment:
description: Await for the deployment to be ready and output the deployment URL
required: false
type: boolean
default: false
vercel-env:
description: Environment variables to create on Vercel, they are scoped to the "preview" environment and the current branch
required: false
type: string
default: DATABASE_URL
vercel-ignored-build-command:
description: Command set for the Ignored Build Step in your project settings, the default script is canceling every preview deployments coming from the Vercel GitHub App.
required: false
type: string
default: curl -sS "https://raw.githubusercontent.com/snaplet/vercel-action/v3/scripts/ignore-build.mjs" | node --input-type=module
# Snaplet action inputs
database-create-command:
description: Command used to generate the instant database
required: false
type: string
default: snaplet database create --git --latest
database-delete-command:
description: Command used to delete the instant database
required: false
type: string
default: snaplet database delete --git
database-url-command:
description: Command used to get the instant database url
required: false
type: string
default: snaplet database url --git
reset:
description: Reset the database state on each commit
required: false
type: boolean
default: false

outputs:
database-url:
description: Instant database url
value: ${{ steps.snaplet.outputs.database-url }}
deployment-url:
description: Preview deployment url
value: ${{ steps.vercel.outputs.deployment-url }}

runs:
using: composite
steps:
- id: snaplet
uses: snaplet/action@v1
with:
delete: ${{ inputs.delete }}
database-create-command: ${{ inputs.database-create-command }}
database-delete-command: ${{ inputs.database-delete-command }}
database-url-command: ${{ inputs.database-url-command }}
reset: ${{ inputs.reset }}
- id: vercel
uses: snaplet/vercel-action@v3
with:
delete: ${{ inputs.delete }}
await-for-deployment: ${{ inputs.vercel-await-for-deployment }}
ignored-build-command: ${{ inputs.vercel-ignored-build-command }}
env: |
${{ inputs.vercel-env }}=${{ steps.snaplet.outputs.database-url }}

0 comments on commit 9c4618b

Please sign in to comment.