-
Notifications
You must be signed in to change notification settings - Fork 5
93 lines (82 loc) · 2.92 KB
/
deploy-preview.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
name: Deploy - Preview
on:
pull_request:
paths:
- "deployment/worms.davideadie.dev/**"
- "build/flyway-summary.sh"
- ".github/workflows/deploy.yml"
jobs:
preview:
name: Azure Infrastructure
runs-on: ubuntu-latest
services:
postgres:
image: postgres
env:
POSTGRES_USER: worms
POSTGRES_PASSWORD: worms
POSTGRES_DB: worms
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.x
- name: Preview Azure Infrastructure
uses: pulumi/actions@v4
id: preview
with:
command: preview
stack-name: prod
work-dir: deployment/worms.davideadie.dev
comment-on-pr: true
github-token: ${{ secrets.GITHUB_TOKEN }}
env:
PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}
ARM_CLIENT_ID: ${{ secrets.ARM_CLIENT_ID }}
ARM_CLIENT_SECRET: ${{ secrets.ARM_CLIENT_SECRET }}
ARM_TENANT_ID: ${{ secrets.ARM_TENANT_ID }}
ARM_SUBSCRIPTION_ID: ${{ secrets.ARM_SUBSCRIPTION_ID }}
- name: Get Database Version
id: database-version
run: echo "version=$(cat deployment/worms.davideadie.dev/database-version.txt)" >> $GITHUB_OUTPUT
- name: Create Reports Folder
run: mkdir src/database/reports
- name: Run Flyway Report
uses: docker://redgate/flyway:9
with:
args: >-
check -changes -drift
-locations="filesystem:/github/workspace/src/database/migrations"
-configFiles="/github/workspace/src/database/flyway.conf"
-url="${{ steps.preview.outputs.database-jdbc }}"
-user="${{ steps.preview.outputs.database-user }}"
-password="${{ steps.preview.outputs.database-password }}"
-check.buildUrl="jdbc:postgresql://postgres:5432/worms"
-check.buildUser="worms"
-check.buildPassword="worms"
-target=${{ steps.database-version.outputs.version }}
-reportFilename="/github/workspace/src/database/reports/report.htm"
env:
FLYWAY_LICENSE_KEY: ${{ secrets.FLYWAY_LICENSE_KEY }}
- name: Get Summary
id: summary
run: echo "summary=$(build/flyway-summary.sh src/database/reports/report.json)" >> $GITHUB_OUTPUT
- name: Comment on PR
uses: thollander/actions-comment-pull-request@v2
with:
mode: recreate
message: |
${{ steps.summary.outputs.summary }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Report
uses: actions/upload-artifact@v3
with:
name: Database Report
path: src/database/reports/