Example GitHub Action Scripts
Published 09 May 2024
Migrate
The following example uses Flyway on Docker and migrates pending migrations to a target database whose connection information is stored as a secret. To access Flyway Teams or Flyway Enterprise features a personal access token and email address need to be provided. These should also be provided as secrets.
name: 'Flyway Migrate'
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Run Flyway Migrate
uses: docker://redgate/flyway:11
with:
args: >-
migrate
-workingDirectory=${{github.workspace}}
-locations="/migrations"
-url="${{ secrets.FLYWAY_URL }}"
-user="${{ secrets.FLYWAY_USER }}"
-password="${{ secrets.FLYWAY_PASSWORD }}"
env:
FLYWAY_EMAIL: ${{ secrets.FLYWAY_EMAIL }}
FLYWAY_TOKEN: ${{ secrets.FLYWAY_TOKEN }}Change and Drift Reports
The following example uses Flyway on Docker and generates a change and drift report. Your target database connection information is stored as a secret and a build environment has been defined in the project's settings. To access Flyway Teams or Flyway Enterprise features a personal access token and email address need to be provided. These should also be provided as secrets.
name: 'Flyway Report'
on: pull_request
jobs:
report:
runs-on: ubuntu-latest
steps:
- name: Run Flyway Report
uses: docker://redgate/flyway:11
with:
args: >-
check -changes -drift
-workingDirectory=${{github.workspace}}
-locations="/migrations"
-url="${{ secrets.FLYWAY_URL }}"
-user="${{ secrets.FLYWAY_USER }}"
-password="${{ secrets.FLYWAY_PASSWORD }}"
-check.buildEnvironment="build"
env:
FLYWAY_EMAIL: ${{ secrets.FLYWAY_EMAIL }}
FLYWAY_TOKEN: ${{ secrets.FLYWAY_TOKEN }}