-
Notifications
You must be signed in to change notification settings - Fork 0
74 lines (67 loc) · 2.42 KB
/
pr_deployment.yml
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
63
64
65
66
67
68
69
70
71
72
73
74
---
name: "Build PR Preview Deployment"
env:
RAILWAY_CONFIG: ${{ secrets.RAILWAY_CONFIG }}
on: [pull_request]
jobs:
deployment:
runs-on: ubuntu-latest
environment: Preview
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Make / update deployment comment
uses: marocchino/sticky-pull-request-comment@v2
with:
message: |
### 🧙 Building PR Deploy Preview for ${{ github.triggering_actor }}
Changes: ${{ github.sha }} ...
- name: "Make vercel configuration directory"
run: |
mkdir .vercel
- name: Create vercel configuration file
uses: jsdaniell/create-json@v1.2.1
with:
name: 'project.json'
json: ${{ secrets.VERCEL_CONFIG }}
dir: '.vercel/'
- name: Prepare and deploy feature branch
id: prepare-and-deploy
run: |
export
npm i -g @railway/cli
cd "$HOME"
mkdir .railway
cd .railway
echo "$RAILWAY_CONFIG" > config.json
cd "$GITHUB_WORKSPACE"
echo "👀 Check railway authentication"
railway whoami
RAILWAY_ENVIRONMENT="katamino-pr-${{ github.event.number }}"
echo "🚉 Railway Environment: $RAILWAY_ENVIRONMENT"
railway environment "$RAILWAY_ENVIRONMENT"
echo "👀 Check railway status?"
railway status
RAILWAY_VARIABLES="$(railway vars)"
DATABASE_URL="$(echo "$RAILWAY_VARIABLES" | \
grep -o "postgresql.*/railway")"
export DATABASE_URL="$DATABASE_URL"
echo "🛠️ npm install"
npm install
#👇 reset DB, migrate & seed
echo "🌈 prisma migrate reset --force"
npx prisma migrate reset --force > /dev/null
echo "🚀 Vercel build"
VERCEL_OUTPUT="$(vercel --token=${{ secrets.VERCEL_TOKEN }} \
--env DATABASE_URL="$DATABASE_URL" \
--build-env DATABASE_URL="$DATABASE_URL" )"
echo "$VERCEL_OUTPUT"
echo "🏁 Finished"
echo VERCEL_OUTPUT="$VERCEL_OUTPUT" >> "$GITHUB_OUTPUT"
- name: Update deployment comment
uses: marocchino/sticky-pull-request-comment@v2
with:
message: |
### ✅ PR Deployment Ready for ${{ github.triggering_actor }}
Deployed ${{ github.sha }} to \
${{ steps.prepare-and-deploy.outputs.VERCEL_OUTPUT }}