|
4 | 4 | branches: |
5 | 5 | - Development |
6 | 6 | paths: |
7 | | - - 'migrations/**' |
| 7 | + - "migrations/**" |
8 | 8 |
|
9 | 9 | # Environment Variables |
10 | 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 | | - |
| 11 | + # Repository Variables - Create these in Project Settings > Variables > Actions |
| 12 | + EMAIL: ${{ vars.USER_EMAIL }} # Use with ${{ env.EMAIL }} |
| 13 | + JDBC_BUILD: ${{ vars.JDBC_BUILD }} |
| 14 | + # BASELINE_VERSION: ${{ vars.BASELINE_VERSION }} |
25 | 15 |
|
| 16 | + # Repository Secrets - Create these in Project Settings > Secrets > Actions |
| 17 | + TOKEN: ${{ secrets.FLYWAY_TOKEN }} |
| 18 | + DB_USER_Build: ${{ secrets.DB_USER_NAME_QA }} |
| 19 | + DB_USER_PW_Build: ${{ secrets.DB_USER_PW_QA }} |
| 20 | + FIRST_UNDO_SCRIPT: ${{ secrets.FIRST_UNDO_SCRIPT }} # Validates all undo scripts up to and including the specified script |
26 | 21 |
|
27 | 22 | # jobs are the steps executed in the workflow |
28 | 23 | 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 |
| 24 | + flyway-build: # Job name |
| 25 | + runs-on: self-hosted # Runner to execute the job |
| 26 | + # runs-on: ubuntu-latest |
| 27 | + defaults: |
| 28 | + run: |
| 29 | + shell: cmd # Default shell. Use Windows Command Prompt |
| 30 | + steps: # Steps are the individual tasks that are executed in the job |
| 31 | + - name: Checkout Repository # Step to check out the repository |
| 32 | + uses: actions/checkout@v4 |
| 33 | + with: |
| 34 | + ref: "Development" # Branch to check out |
| 35 | + fetch-depth: 0 # Fetch the entire history to avoid shallow clone issues |
| 36 | + clean: true # Ensure the repository is cleaned before the workflow runs |
| 37 | + |
| 38 | + # Runs the Flyway Clean command against the Build database |
| 39 | + - name: Clean Build DB |
| 40 | + run: | |
| 41 | + 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.JDBC_BUILD }} -IAgreeToTheEula -locations="filesystem:${{ github.workspace }}/migrations" -configFiles="${{ github.workspace }}/flyway.toml" -baselineOnMigrate=true -errorOverrides=S0001:0:I- |
43 | 42 |
|
| 43 | + - name: Migrate Build # Step to run Flyway migrations |
| 44 | + # 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. |
| 45 | + run: flyway -email=${{ env.EMAIL }} -token=${{ env.TOKEN }} migrate -cleanDisabled="false" -user=${{ env.DB_USER_Build }} -password=${{ env.DB_USER_PW_Build }} -url=${{ env.JDBC_BUILD }} -IAgreeToTheEula -locations="filesystem:${{ github.workspace }}/migrations" -configFiles="${{ github.workspace }}/flyway.toml" -baselineOnMigrate=true -errorOverrides=S0001:0:I- |
| 46 | + working-directory: ./migrations |
44 | 47 |
|
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 |
| 48 | + - name: Rollback Build # Step to run Flyway migrations |
| 49 | + run: flyway -email=${{ env.EMAIL }} -token=${{ env.TOKEN }} undo -cleanDisabled="false" -user=${{ env.DB_USER_Build }} -password=${{ env.DB_USER_PW_Build }} -url=${{ env.JDBC_BUILD }} -target=${{ env.FIRST_UNDO_SCRIPT }} -IAgreeToTheEula -locations="filesystem:${{ github.workspace }}/migrations" -configFiles="${{ github.workspace }}/flyway.toml" -baselineOnMigrate=true -errorOverrides=S0001:0:I- |
| 50 | + working-directory: ./migrations |
0 commit comments