6.1 Deploying Your Changes via GitHub Actions

Now that you've committed your migration scripts to the hosted repository, it's time to set up continuous integration and deployment (CI/CD) using GitHub Actions. This setup allows your database changes to be automatically applied across all environments, ensuring a smooth deployment process.

Tip: These YAML pipelines read from the Flyway project to know the locations of the target databases! When provisioning your databases, we updated the connections in Flyway Desktop to point to the newly created databases. If the pipeline encounters issues finding a database, double-check that your Flyway project has the correct and working connections to these databases. Refer back to Provisioning your Databases for more details and troubleshooting tips.

Remeber: If you need a trial key for Flyway Enterprise, you're in luck! You can easily get a free trial to explore the full range of features, onboard your team, or understand our offerings better via Flyway AutoPilot. Simply visit here to start your free trial today. If you have a contact at Redgate, you can also request a trial key for Flyway AutoPilot directly from them. Alternatively, you can reach out to the AutoPilot team at flywayap@red-gate.com for a license.

Step-by-Step Guide

Step-by-Step Guide

  1. Navigate to GitHub Actions

    • Go to your GitHub repository and click on Actions in the top menu. You will likely need to enable actions on the repository before carrying on, as seen below!
  2. Locate the Workflow Files

    • The repository is already set up with multiple workflows designed for different operating systems.
    • In the repository’s file structure, navigate to the .github/workflows folder. Inside, you will find several YAML scripts clearly labeled with an OS suffix based on the operating system of your self-hosted runner (e.g., windows.yml, linux.yml).
    • Do not run any workflows yet—we need to configure the runner and license first.

Configuring Your Self-Hosted Runner

  1. Add a Self-Hosted Runner
    • Navigate to Settings in your GitHub repository.
    • In the left-hand menu, click on Actions > Runners and select New self-hosted runner.
    • Follow the instructions provided for your specific operating system (Windows, Linux, or macOS) to set up the runner.
    • Once installed, this runner will serve as the environment that runs the Flyway commands in your CI/CD pipeline.

Adding a Flyway License Key

  1. Set Up Flyway License Key
    • Flyway requires a valid license to run migrations as part of your pipeline. You’ll need to add this as a secret in GitHub.
    • In your GitHub repository:
      • Go to Settings > Secrets and variables > Actions on the left-hand menu.
      • Click New repository secret and set the Name to FLYWAY_LICENSE_KEY.
      • Enter your Flyway Enterprise trial key or license key, and click Add secret.

        Tip: Flyway Enterprise trials are always available. If you have a contact at Redgate already reach out to them for a free trial to use for AutoPilot. Alternatively head to this link or reach out directly to the AutoPilot team : flywayap@red-gate.com

Editing the Workflow Files

  1. Configure the Workflow
    • Open the .github/workflows folder and locate the YAML file that matches the operating system of your self-hosted runner (e.g., windows.yml for Windows-based runners).
    • The workflows are pre-configured to use localhost:1433 for database connections. If your databases are hosted elsewhere, modify the connection strings in the YAML file to point to the correct server, instance, and port.
    • Review any additional settings in the workflow that may need customization, such as environment variables or paths.

Running the Workflow

  1. Run the Workflow

    • After setting up the runner and editing the workflow file, go back to the Actions tab in GitHub.
    • Select the appropriate workflow (e.g., windows.yml) and click Run workflow.
  2. Monitor the Workflow

    • Once the workflow starts, you can click on the workflow run to monitor its progress. It may show as Queued if the runner is not yet available.
    • Make sure the runner is correctly installed and active, as it will execute the Flyway commands for the pipeline.
  3. Check Logs and Output

    • Click on the individual jobs within the workflow (such as Deploy Build) to view detailed logs of the Flyway commands being executed.
    • You should see the Flyway commands running to apply your migration scripts and any database changes detected.

Post-Deployment

  1. Review Deployment Reports
    • After the workflow completes, check the deployment reports generated by Flyway. These will show the status of your migrations, any changes that were successfully applied, and any drift or errors detected.
    • The reports will either be part of the workflow output or accessible directly in the repository.

Next Steps

Now that your CI/CD pipeline is set up with GitHub Actions, Flyway AutoPilot will handle automatic database migrations across your environments. This setup ensures that changes are versioned, tested, and deployed consistently, helping you maintain control over database development.


Didn't find what you were looking for?