-
Notifications
You must be signed in to change notification settings - Fork 0
62 lines (56 loc) · 2.03 KB
/
Copy pathmigrate-neon.yml
File metadata and controls
62 lines (56 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
name: Migrate Neon database
on:
push:
branches: [main, release]
workflow_dispatch:
inputs:
neon_branch:
description: "Neon branch to migrate (production | staging | dev)"
required: true
default: "production"
jobs:
migrate:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "20"
cache: npm
- name: Install dependencies
run: npm install --force
- name: Resolve connection URL
id: db
env:
DATABASE_URL_UNPOOLED_PRODUCTION: ${{ secrets.DATABASE_URL_UNPOOLED_PRODUCTION }}
DATABASE_URL_UNPOOLED_STAGING: ${{ secrets.DATABASE_URL_UNPOOLED_STAGING }}
DATABASE_URL_UNPOOLED_DEV: ${{ secrets.DATABASE_URL_UNPOOLED_DEV }}
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
BRANCH="${{ github.event.inputs.neon_branch }}"
elif [ "${{ github.ref }}" = "refs/heads/release" ]; then
BRANCH="production"
else
BRANCH="staging"
fi
echo "branch=$BRANCH" >> "$GITHUB_OUTPUT"
case "$BRANCH" in
production) URL="$DATABASE_URL_UNPOOLED_PRODUCTION" ;;
staging) URL="$DATABASE_URL_UNPOOLED_STAGING" ;;
dev) URL="$DATABASE_URL_UNPOOLED_DEV" ;;
*) echo "Unknown branch: $BRANCH"; exit 1 ;;
esac
if [ -z "$URL" ]; then
echo "Missing secret for Neon branch: $BRANCH"
exit 1
fi
echo "DATABASE_URL_UNPOOLED=$URL" >> "$GITHUB_ENV"
echo "DATABASE_URL=$URL" >> "$GITHUB_ENV"
- name: Run migrations
env:
# Needed only if AuthorizationRefactor (or similar) still has to run.
# Safe when unset if that migration is already recorded as applied.
FIREBASE_SERVICE_ACCOUNT_JSON: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_JSON }}
run: npm run db:migrate