Deployment of refs/heads/release/1.0 to PROD by dreads #3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##################################################################### | |
# GitHub Action to perform manual deployment of database | |
# changes using Liquibase Pro, Liquibase Pro Flows, and Custom | |
# Policy checks. | |
##################################################################### | |
name: 'Liquibase Pro Deployment Workflow' | |
run-name: Deployment of ${{github.ref}} to ${{ inputs.environment }} by ${{ github.actor }} | |
on: | |
workflow_dispatch: | |
# Following are the inputs received via the GitHub Actions Run workflow dialog | |
inputs: | |
# The type 'environment' will automatically pull in the environments created in Settings->Environments | |
environment: | |
description: 'Environment to deploy to' | |
type: environment | |
required: true | |
# For more info on log level, see: https://docs.liquibase.com/parameters/log-level.html | |
log-level: | |
description: 'Liquibase log level' | |
required: false | |
default: 'INFO' | |
type: choice | |
options: [ 'SEVERE','WARNING','INFO','FINE','OFF' ] | |
#################################################################### | |
# Set up the environment | |
##################################################################### | |
env: | |
# The top level Flow File that gets cloned into the workspace from | |
# the Liquibase Configuration Repo which orchestrates the database changes. | |
# See https://docs.liquibase.com/commands/flow/flow.html | |
FLOW_FILE: "flowfiles/liquibase-postmerge.flowfile.yaml" | |
# The Liquibase Search Path controls how Liquibase finds it's configurations. | |
# To ensure the correct config gets located first, keep "." at the end of this path. | |
# See https://docs.liquibase.com/concepts/changelogs/how-liquibase-finds-files.html | |
LIQUIBASE_SEARCH_PATH: "." | |
# Location of the Custom Policy Checks settings file from the Liquibase Configuration Repo. | |
# See https://docs.liquibase.com/liquibase-pro/policy-checks/custom-policy-checks/home.html | |
LIQUIBASE_COMMAND_CHECKS_SETTINGS_FILE: "policychecks/liquibase.checks-settings.conf" | |
# Store the Liquibase Pro License key in a Github Action Repository Secret. The | |
# same license key is used for all executions, so it is tracked at the repository level | |
# See https://docs.liquibase.com/workflows/liquibase-pro/how-to-apply-your-liquibase-pro-license-key.html | |
LIQUIBASE_LICENSE_KEY: ${{ secrets.LIQUIBASE_PRO_LICENSE_KEY }} | |
# JDBC URL of the database per environment. Based on the incoming branch (one of DEV, QA, or PROD), | |
# the corresponding secret will be taken from the Environment secrets. | |
# See https://docs.liquibase.com/workflows/liquibase-community/using-jdbc-url-in-liquibase.html | |
LIQUIBASE_COMMAND_URL: ${{ secrets.LIQUIBASE_COMMAND_URL }} | |
# Credentials for the environment's database. Based on the incoming branch (one of DEV, QA, or PROD), | |
# the corresponding secrets will be taken from the Environment secrets. | |
# See https://docs.liquibase.com/parameters/command-parameters.html | |
LIQUIBASE_COMMAND_USERNAME: ${{ secrets.LIQUIBASE_COMMAND_USERNAME }} | |
LIQUIBASE_COMMAND_PASSWORD: ${{ secrets.LIQUIBASE_COMMAND_PASSWORD }} | |
# Logging Settings | |
# See https://docs.liquibase.com/parameters/log-format.html | |
LIQUIBASE_LOG_FORMAT: JSON | |
LIQUIBASE_LOG_LEVEL: INFO | |
jobs: | |
#################################################################### | |
# Initialization runs first because it has no 'needs' value. | |
#################################################################### | |
init: | |
name: Initialization | |
# This runs on a self-hosted runner with Liquibase preinstalled. | |
runs-on: [self-hosted] | |
outputs: | |
environment: ${{ steps.set-environment.outputs.environment }} | |
steps: | |
# Cancel any previous runs that are not completed for this workflow | |
- name: Cancel previous workflow | |
uses: styfle/[email protected] | |
with: | |
access_token: ${{ github.token }} | |
# Determine the environment based on the branch(es) that triggered this workflow. | |
# Output "DEV", "QA", or "PROD" to $GITHUB_OUTPUT where job output parameters are | |
# shared between jobs. | |
- name: Set Environment | |
id: set-environment | |
run: | | |
echo "environment=DEV" >> $GITHUB_OUTPUT | |
if [[ "${{ inputs.environment }}" == QA ]]; then | |
echo "environment=QA" >> $GITHUB_OUTPUT | |
fi | |
if [[ "${{ inputs.environment }}" == PROD ]]; then | |
echo "environment=PROD" >> $GITHUB_OUTPUT | |
fi | |
################################################################### | |
# Check out the source code | |
#################################################################### | |
checkout-repo: | |
name: Check out repositories | |
needs: [init] | |
runs-on: [self-hosted] | |
steps: | |
# Check out the database change configuration code and workflows | |
- name: Checkout Database Change Configuration repo | |
uses: actions/checkout@v3 | |
# Check out the SQL Repo to a folder, "liquibase-sql" | |
- name: Checkout Database Change SQL repo | |
uses: actions/checkout@v4 | |
with: | |
repository: liquibase/cs-impl-guide-examples-sql | |
path: liquibase-sql | |
#################################################################### | |
# Perform the Database change control operations specified | |
# in the flowfile. In this case, deploy the database changes. | |
##################################################################### | |
liquibase-deployment: | |
name: Database Deployment | |
needs: [init, checkout-repo] | |
runs-on: [self-hosted] | |
environment: ${{needs.init.outputs.environment}} | |
steps: | |
# Execute the Flow file | |
- name: Run flow | |
run: | | |
liquibase --license-key=${{ env.LIQUIBASE_LICENSE_KEY }} flow \ | |
--flow-file=${{ env.FLOW_FILE }} \ | |
--logfile=logs/liquibase.log |