Skip to content

Merge pull request #312 from GTBitsOfGood/fix_profile_dropdown_bug #792

Merge pull request #312 from GTBitsOfGood/fix_profile_dropdown_bug

Merge pull request #312 from GTBitsOfGood/fix_profile_dropdown_bug #792

Workflow file for this run

name: CD
on:
push:
branches:
- main
pull_request:
branches:
- main
types:
- synchronize
workflow_dispatch:
jobs:
migrate-db:
runs-on: ubuntu-latest
environment: ${{ github.ref_name == 'main' && 'Staging' || 'Preview' }}
permissions:
contents: write
steps:
- uses: actions/checkout@v7
- name: Setup pnpm
uses: pnpm/action-setup@v5.0.0
- name: Install dependencies
run: pnpm install
- name: Check migrations
run: pnpm run db:check
- name: Load DB_URL from secrets
run: echo "DB_URL=${{ secrets.DB_URL }}${{ github.ref_name != 'main' && '/pr' || '' }}${{ github.ref_name != 'main' && github.event.number || '' }}" >> $GITHUB_ENV
- name: Ensure preview database exists
if: github.ref_name != 'main'
run: |
psql "${{ secrets.DB_URL }}/postgres" -tAc "SELECT 1 FROM pg_database WHERE datname = 'pr${{ github.event.number }}'" | grep -q 1 || \
psql "${{ secrets.DB_URL }}/postgres" -c 'create database "pr${{ github.event.number }}";'
- name: Migrate database
run: pnpm run db:migrate