Skip to content

Commit dc7d358

Browse files
updated github actions workflows
1 parent fe92e49 commit dc7d358

File tree

3 files changed

+190
-0
lines changed

3 files changed

+190
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Flyway GitHub Actions Build Workflow # Workflow name
2+
on:
3+
push:
4+
branches:
5+
- Development
6+
paths:
7+
- 'migrations/**'
8+
9+
# Environment Variables
10+
env:
11+
# Repository Variables - Create these in Project Settings > Variables > Actions
12+
EMAIL: ${{ vars.USER_EMAIL }} # Use with ${{ env.EMAIL }}
13+
DB_SERVER: ${{ vars.DB_SERVER }}
14+
DB_Build: ${{ vars.DB_NAME_Build }}
15+
ENCRYPT: ${{ vars.ENCRYPT_BOOL }}
16+
TRUST_CERT: ${{ vars.TRUST_CERT_BOOL }}
17+
# BASELINE_VERSION: ${{ vars.BASELINE_VERSION }}
18+
19+
# Repository Secrets - Create these in Project Settings > Secrets > Actions
20+
TOKEN: ${{ secrets.FLYWAY_TOKEN }}
21+
DB_USER_Build: ${{ secrets.DB_USER_NAME_QA }}
22+
DB_USER_PW_Build: ${{ secrets.DB_USER_PW_QA }}
23+
FIRST_UNDO_SCRIPT: ${{ secrets.FIRST_UNDO_SCRIPT }} # Validates all undo scripts up to and including the specified script
24+
25+
26+
27+
# jobs are the steps executed in the workflow
28+
jobs:
29+
flyway-build: # Job name
30+
runs-on: self-hosted # Runner to execute the job
31+
# runs-on: ubuntu-latest
32+
defaults:
33+
run:
34+
shell: cmd # Default shell. Use Windows Command Prompt
35+
36+
steps: # Steps are the individual tasks that are executed in the job
37+
- name: Checkout Repository # Step to check out the repository
38+
uses: actions/checkout@v4
39+
with:
40+
ref: "Development" # Branch to check out
41+
fetch-depth: 0 # Fetch the entire history to avoid shallow clone issues
42+
clean: true # Ensure the repository is cleaned before the workflow runs
43+
44+
45+
# Runs the Flyway Clean command against the Build database
46+
- name: Clean Build DB
47+
run: |
48+
flyway -email=${{ env.EMAIL }} -token=${{ env.TOKEN }} info clean info -cleanDisabled="false" -user=${{ env.DB_USER_Build }} -password=${{ env.DB_USER_PW_Build }} -url="${{ env.DB_SERVER }};databaseName=${{ env.DB_Build }};encrypt=${{ env.ENCRYPT }};trustServerCertificate=${{ env.TRUST_CERT }}" -IAgreeToTheEula -locations="filesystem:${{ github.workspace }}/migrations" -configFiles="${{ github.workspace }}/flyway.toml" -baselineOnMigrate=true -errorOverrides=S0001:0:I-
49+
50+
- name: Migrate Build # Step to run Flyway migrations
51+
# To use username and password instead of windows integrated security Ensure that SQL Server is configured to allow SQL Server authentication. You can check this in SQL Server Management Studio (SSMS) under the server properties -> Security -> Server authentication. Ensure "SQL Server and Windows Authentication mode" is selected.
52+
run: flyway -email=${{ env.EMAIL }} -token=${{ env.TOKEN }} migrate -cleanDisabled="false" -user=${{ env.DB_USER_Build }} -password=${{ env.DB_USER_PW_Build }} -url="${{ env.DB_SERVER }};databaseName=${{ env.DB_Build }};encrypt=${{ env.ENCRYPT }};trustServerCertificate=${{ env.TRUST_CERT }}" -IAgreeToTheEula -locations="filesystem:${{ github.workspace }}/migrations" -configFiles="${{ github.workspace }}/flyway.toml" -baselineOnMigrate=true -errorOverrides=S0001:0:I-
53+
working-directory: ./migrations
54+
55+
- name: Rollback Build # Step to run Flyway migrations
56+
run: flyway -email=${{ env.EMAIL }} -token=${{ env.TOKEN }} undo -cleanDisabled="false" -user=${{ env.DB_USER_Build }} -password=${{ env.DB_USER_PW_Build }} -url="${{ env.DB_SERVER }};databaseName=${{ env.DB_Build }};encrypt=${{ env.ENCRYPT }};trustServerCertificate=${{ env.TRUST_CERT }}" -target="${{ env.FIRST_UNDO_SCRIPT }}" -IAgreeToTheEula -locations="filesystem:${{ github.workspace }}/migrations" -configFiles="${{ github.workspace }}/flyway.toml" -baselineOnMigrate=true -errorOverrides=S0001:0:I-
57+
working-directory: ./migrations
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: Flyway GitHub Actions Production Workflow # Workflow name
2+
on:
3+
push:
4+
branches:
5+
- Production
6+
# paths:
7+
# - 'migrations/**'
8+
9+
# Environment Variables
10+
env:
11+
# Repository Variables - Create these in Project Settings > Variables > Actions
12+
EMAIL: ${{ vars.USER_EMAIL }} # Use with ${{ env.EMAIL }}
13+
DB_SERVER: ${{ vars.DB_SERVER }}
14+
DB_CHECK: ${{ vars.DB_NAME_CHECK }}
15+
DB_PROD_1: ${{ vars.DB_NAME_PROD_1 }}
16+
DB_PROD_2: ${{ vars.DB_NAME_PROD_2 }}
17+
ENCRYPT: ${{ vars.ENCRYPT_BOOL }}
18+
TRUST_CERT: ${{ vars.TRUST_CERT_BOOL }}
19+
# BASELINE_VERSION: ${{ vars.BASELINE_VERSION }}
20+
21+
# Repository Secrets - Create these in Project Settings > Secrets > Actions
22+
TOKEN: ${{ secrets.FLYWAY_TOKEN }}
23+
DB_USER_PROD: ${{ secrets.DB_USER_NAME_QA }}
24+
DB_USER_PW_PROD: ${{ secrets.DB_USER_PW_QA }}
25+
# FIRST_UNDO_SCRIPT: ${{ secrets.FIRST_UNDO_SCRIPT }} # Validates all undo scripts up to and including the specified script
26+
PROD_1_JDBC: "${{ vars.DB_SERVER }};databaseName=${{ vars.DB_NAME_PROD_1 }};encrypt=${{ vars.ENCRYPT_BOOL }};trustServerCertificate=${{ vars.TRUST_CERT_BOOL }}"
27+
PROD_2_JDBC: "${{ vars.DB_SERVER }};databaseName=${{ vars.DB_NAME_PROD_2 }};encrypt=${{ vars.ENCRYPT_BOOL }};trustServerCertificate=${{ vars.TRUST_CERT_BOOL }}"
28+
CHECK_JDBC: "${{ vars.DB_SERVER }};databaseName=${{ vars.DB_CHECK }};encrypt=${{ vars.ENCRYPT_BOOL }};trustServerCertificate=${{ vars.TRUST_CERT_BOOL }}"
29+
30+
# End of Environment Secrets #
31+
generateDriftAndChangeReport: true
32+
failReleaseIfDriftDetected: false
33+
staticCodeAnalysis: false #Currently not setup in this pipeline
34+
publishArtifacts: true
35+
36+
# jobs are the steps executed in the workflow
37+
jobs:
38+
39+
flyway-report-prod:
40+
name: Generate Report
41+
runs-on: self-hosted # Runner to execute the job
42+
defaults:
43+
run:
44+
shell: cmd # Default shell. Use Windows Command Prompt
45+
46+
steps: # Steps are the individual tasks that are executed in the job
47+
- uses: actions/checkout@v4 # Check out the repository
48+
with: # Additional options for the action
49+
ref: "Production" # Branch to check out
50+
51+
- name: Create Drift and Change Report
52+
run: |
53+
flyway -email=${{ env.EMAIL }} -token=${{ env.TOKEN }} check -dryrun -changes -drift -check.buildUser=${{ env.DB_USER_PROD }} -check.buildPassword=${{ env.DB_USER_PW_PROD }} -check.buildEnvironment="${{ env.CHECK_JDBC }}" -user=${{ env.DB_USER_PROD }} -password=${{ env.DB_USER_PW_PROD }} -url="${{ env.DB_SERVER }};databaseName=${{ env.DB_PROD_2 }};encrypt=${{ env.ENCRYPT }};trustServerCertificate=${{ env.TRUST_CERT }}" -reportFilename="${{ github.workspace }}\reports\${{ env.DB_PROD_2 }}-Run-${{ github.run_id }}-Check-Report.html" -IAgreeToTheEula -locations="filesystem:${{ github.workspace }}/migrations" -configFiles="${{ github.workspace }}/flyway.toml" -baselineOnMigrate=true -errorOverrides=S0001:0:I-
54+
continue-on-error: true
55+
56+
# Create a directory to stage the artifact files
57+
- name: Stage files for publishing
58+
run: |
59+
xcopy /E /I "${{ github.workspace }}\reports" "Artifact_Files\Reports\"
60+
61+
- name: Publish Check Report as Artifact
62+
uses: actions/upload-artifact@v4
63+
with:
64+
name: flyway-reports
65+
path: Artifact_Files/Reports/
66+
67+
68+
flyway-deploy-prod:
69+
runs-on: self-hosted # Runner to execute the job
70+
defaults:
71+
run:
72+
shell: cmd # Default shell. Use Windows Command Prompt
73+
74+
steps: # Steps are the individual tasks that are executed in the job
75+
- uses: actions/checkout@v4 # Check out the repository
76+
with: # Additional options for the action
77+
ref: "Production" # Branch to check out
78+
79+
- name: Deploy to Prod 1 # Step to run Flyway migrations
80+
# To use username and password instead of windows integrated security Ensure that SQL Server is configured to allow SQL Server authentication. You can check this in SQL Server Management Studio (SSMS) under the server properties -> Security -> Server authentication. Ensure "SQL Server and Windows Authentication mode" is selected.
81+
run: flyway -email=${{ env.EMAIL }} -token=${{ env.TOKEN }} migrate -user=${{ env.DB_USER_PROD }} -password=${{ env.DB_USER_PW_PROD }} -url="${{ env.DB_SERVER }};databaseName=${{ env.DB_PROD_1 }};encrypt=${{ env.ENCRYPT }};trustServerCertificate=${{ env.TRUST_CERT }}" -IAgreeToTheEula -locations="filesystem:${{ github.workspace }}/migrations" -configFiles="${{ github.workspace }}/flyway.toml" -baselineOnMigrate=true -errorOverrides=S0001:0:I-
82+
# Multi-tenant deployment. Add second deployment to PROD2 here
83+
working-directory: ./migrations
84+
85+
- name: Deploy to Prod 2 # Step to run Flyway migrations
86+
# To use username and password instead of windows integrated security Ensure that SQL Server is configured to allow SQL Server authentication. You can check this in SQL Server Management Studio (SSMS) under the server properties -> Security -> Server authentication. Ensure "SQL Server and Windows Authentication mode" is selected.
87+
run: flyway -email=${{ env.EMAIL }} -token=${{ env.TOKEN }} info migrate info -user=${{ env.DB_USER_PROD }} -password=${{ env.DB_USER_PW_PROD }} -url="${{ env.DB_SERVER }};databaseName=${{ env.DB_PROD_2 }};encrypt=${{ env.ENCRYPT }};trustServerCertificate=${{ env.TRUST_CERT }}" -IAgreeToTheEula -locations="filesystem:${{ github.workspace }}/migrations" -configFiles="${{ github.workspace }}/flyway.toml" -baselineOnMigrate=true -errorOverrides=S0001:0:I-
88+
# Multi-tenant deployment. Add second deployment to PROD2 here
89+
working-directory: ./migrations
90+
91+
# Sample for integrated security instead of user name and password
92+
# -url="${{ env.DB_SERVER }};databaseName=${{ env.DB_PROD_1 }};encrypt=${{ env.ENCRYPT }};integratedSecurity=true;trustServerCertificate=${{ env.TRUST_CERT }}"
93+
# -baselineVersion=${{ env.BASELINE_VERSION }}
94+
# -user=${{ env.DB_USER_PROD }} -password=${{ env.DB_USER_PW_PROD }}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Flyway GitHub Actions QA Workflow
2+
on:
3+
push:
4+
branches:
5+
- QA
6+
paths:
7+
- 'migrations/**'
8+
9+
env:
10+
EMAIL: ${{ vars.USER_EMAIL }}
11+
DB_SERVER: ${{ vars.DB_SERVER }}
12+
DB_QA: ${{ vars.DB_NAME_QA }}
13+
ENCRYPT: ${{ vars.ENCRYPT_BOOL }}
14+
TRUST_CERT: ${{ vars.TRUST_CERT_BOOL }}
15+
TOKEN: ${{ secrets.FLYWAY_TOKEN }}
16+
DB_USER_QA: ${{ secrets.DB_USER_NAME_QA }}
17+
DB_USER_PW_QA: ${{ secrets.DB_USER_PW_QA }}
18+
# BASELINE_VERSION: ${{ vars.BASELINE_VERSION }}
19+
# FIRST_UNDO_SCRIPT: ${{ secrets.FIRST_UNDO_SCRIPT }}
20+
21+
22+
jobs:
23+
flyway-deploy-qa:
24+
runs-on: self-hosted # Runner to execute the job
25+
# runs-on: ubuntu-latest
26+
defaults:
27+
run:
28+
shell: cmd # Default shell. Use Windows Command Prompt
29+
30+
steps: # Steps are the individual tasks that are executed in the job
31+
- uses: actions/checkout@v4 # Check out the repository
32+
with: # Additional options for the action
33+
ref: "QA" # Branch to check out
34+
35+
- name: Deploy to QA # Step to run Flyway migrations
36+
# To use username and password instead of windows integrated security Ensure that SQL Server is configured to allow SQL Server authentication. You can check this in SQL Server Management Studio (SSMS) under the server properties -> Security -> Server authentication. Ensure "SQL Server and Windows Authentication mode" is selected.
37+
run: flyway -email=${{ env.EMAIL }} -token=${{ env.TOKEN }} info migrate info -user=${{ env.DB_USER_QA }} -password=${{ env.DB_USER_PW_QA }} -url="${{ env.DB_SERVER }};databaseName=${{ env.DB_QA }};encrypt=${{ env.ENCRYPT }};trustServerCertificate=${{ env.TRUST_CERT }}" -IAgreeToTheEula -locations="filesystem:${{ github.workspace }}/migrations" -configFiles="${{ github.workspace }}/flyway.toml" -baselineOnMigrate=true -errorOverrides=S0001:0:I-
38+
working-directory: ./migrations
39+

0 commit comments

Comments
 (0)