Skip to content

Trying a review environment w/ deploy-preview.yml #26

Trying a review environment w/ deploy-preview.yml

Trying a review environment w/ deploy-preview.yml #26

name: Preview Deployment
on: [pull_request]
jobs:
deploy-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: pnpm/action-setup@v2
with:
version: 8
- uses: actions/setup-node@v4
with:
node-version: 18
cache: "pnpm"
- run: pnpm install
- name: Get git branch name
id: branch-name
uses: tj-actions/branch-names@v8
- id: create-branch
uses: neondatabase/create-branch-action@v5
with:
project_id: ${{ vars.NEON_PROJECT_ID }} # You can find this in your Neon project settings
username: "neondb_owner" # Change this to the role you use to connect to your database
# parent: dev # optional (defaults to your primary branch)
branch_name: preview/${{ steps.branch-name.outputs.current_branch }}
api_key: ${{ secrets.NEON_API_KEY }} # Generate an API key in your Neon account settings
- run: |
echo "DATABASE_URL=${{ steps.create-branch.outputs.db_url_with_pooler }}" >> "$GITHUB_ENV"
- run: pnpm run db:migrate
- id: deploy
uses: superfly/[email protected]
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} # You can generate a Fly API token in your account settings
with:
secrets: DATABASE_URL=$DATABASE_URL