Last active
May 15, 2024 06:19
-
-
Save clarkbw/1ccae701bf3d2e34dbd829d34a70767e to your computer and use it in GitHub Desktop.
Ideal GitHub Action for Fly preview w/ Neon database
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: PR Review | |
on: | |
# Run this workflow on every PR event. Existing review apps will be updated when the PR is updated. | |
# Neon branches are created and removed according to PR updates | |
pull_request: | |
types: [opened, reopened, synchronize, closed] | |
jobs: | |
pr-preview: | |
runs-on: ubuntu-latest | |
outputs: | |
url: ${{ steps.deploy.outputs.url }} | |
# Only run one deployment at a time per PR. | |
concurrency: | |
group: pr-${{ github.event.number }} | |
environment: | |
name: review | |
url: ${{ steps.deploy.outputs.url }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
- run: npm install | |
# exports DATABASE_URL to use in next steps | |
- uses: neondatabase/pr-review-branch@v1 | |
- run: npm run db:migrate | |
- id: deploy | |
uses: superfly/[email protected] | |
with: | |
secrets: DATABASE_URL=${{ env.DATABASE_URL }} | |
env: | |
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As for the inputs...
There are two core ones required:
NEON_PROJECT_ID
should come from the GitHub AppNEON_API_KEY
should also come from the GitHub AppI think we can make assumptions about all the other inputs. (1 database, 1 role) And if it's more complex we complain and ask people to add the necessary inputs to let us know which role and which database etc.