-
Notifications
You must be signed in to change notification settings - Fork 0
47 lines (38 loc) · 1.48 KB
/
migrate_deploy.yml
File metadata and controls
47 lines (38 loc) · 1.48 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
name: Database Migrations and Deploy
on:
workflow_dispatch:
inputs:
branch:
description: 'Branch to run the workflow'
required: true
default: 'release'
jobs:
migrate-and-deploy:
runs-on: ubuntu-latest
if: github.event.inputs.branch == 'release'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.x'
- name: Install dotnet-ef Tool
run: dotnet tool install --global dotnet-ef
- name: Restore Dependencies
run: dotnet restore Shortify.NET.API/Shortify.NET.API.csproj
- name: Generate Migration Script
run: dotnet ef migrations script --idempotent --context AppDbContext --startup-project Shortify.NET.API/Shortify.NET.API.csproj --project Shortify.NET.Persistence/Shortify.NET.Persistence.csproj -o migrations.sql
- name: Apply Migration Script
env:
PGHOST: ${{ secrets.DATABASE_HOST }}
PGPORT: ${{ secrets.DATABASE_PORT }}
PGUSER: ${{ secrets.DATABASE_USER }}
PGPASSWORD: ${{ secrets.DATABASE_PASSWORD }}
PGDATABASE: ${{ secrets.DATABASE_NAME }}
run: psql -h $PGHOST -p $PGPORT -U $PGUSER -d $PGDATABASE -f migrations.sql $PGPASSWORD
- name: Deploy to Render
env:
deploy_url: ${{ secrets.RENDER_DEPLOY_HOOK_URL }}
run: |
curl "$deploy_url"