Liquibase Update Error in GitHub Workflow

Hi everyone! I’m attempting to set up a series of GitHub actions for version control in BigQuery schemas using Liquibase. My liquibase.properties file is as follows:

# Database connection details
url=jdbc:bigquery://https://www.googleapis.com/bigquery/v2:publicdata;ProjectId=my-dev
username=your-username
password=your-password

# BigQuery-specific properties
driver=com.simba.googlebigquery.jdbc.Driver

# Location of the private key JSON file
# Ensure this file is securely managed and not exposed in the repository.
# In a real setup, you would use a GitHub Actions secret for the key file
keyFilePath=/tmp/bigquery-key.json

# Change Log File
changeLogFile=db/changelog/db.changelog-master.sql

# Optional: Default schema for Liquibase (not typically used with BigQuery, but included for completeness)
defaultSchemaName=your-schema

# Optional: Database change log table names (optional, defaults are 'DATABASECHANGELOG' and 'DATABASECHANGELOGLOCK')
databaseChangeLogTableName=DATABASECHANGELOG
databaseChangeLogLockTableName=DATABASECHANGELOGLOCK

FYI, I’m including username and pw settings in the properties file only because I thought they were needed. However, I authenticate using a private key instead.

And my workflow file is below:

name: Liquibase BigQuery

on:
  push:
    branches:
      - deploy-to-bq-dev

jobs:
  liquibase:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v3

      - name: Set up Java
        uses: actions/setup-java@v3
        with:
          java-version: '21'
          distribution: 'corretto'

      - name: Verify Java Installation
        run: |
          echo "JAVA_HOME is $JAVA_HOME"
          ls -ld $JAVA_HOME
          ls -l $JAVA_HOME/bin
          java -version

      - name: Export JAVA_HOME
        run: |
          echo "JAVA_HOME=/opt/hostedtoolcache/Java_Corretto_jdk/21.0.4-7.1/x64" >> $GITHUB_ENV
          echo "JAVA_HOME is $JAVA_HOME"

      - name: Liquibase Update Action
        env:
          JAVA_HOME: ${{ env.JAVA_HOME }}
        uses: liquibase-github-actions/update@v4.29.0
        with:
          changelogFile: "db/changelog/db.changelog-master.sql"
          url: "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:publicdata;ProjectId=my-dev"

The error occurs only in the last step (“Liquibase Update Action”). It reads: “ERROR: The JAVA_HOME environment variable is not defined correctly, so Liquibase cannot be started. JAVA_HOME is set to “/opt/hostedtoolcache/Java_Corretto_jdk/21.0.4-7.1/x64” and it does not exist.”

Naturally, my changelog failed to execute as a result.

I added the steps “Verify Java Installation” and “Export JAVA_HOME” in an attempt to verify that JAVA_HOME was indeed getting set properly. And the variable does display successfully.

But I admit I’m a GitHub and Liquibase newbie and could use some help. Any thoughts about how to correct this error?

@rcfountain01 have you tried using the GH Actions without the java piece? I have an example here that just does update.

That actually wouldn’t be viable in this case. I have to use a private key json file provided to me.

I’ve redesigned my workflow to the following:

name: Liquibase Update

on:
  push:
    branches:
      - deploy-to-bq-dev

jobs:
  test-liquibase-action:
    runs-on: ubuntu-latest
    name: Test Liquibase Update
    steps:

      - name: Create Private Key File
        env:
          GCP_PRIVATE_KEY: ${{ secrets.LB_BQ_DEV_PRIVATE_KEY }}
        run: |
          pwd
          mkdir tmp
          echo "$GCP_PRIVATE_KEY" > /home/runner/work/BigQuery-Schema-Test/BigQuery-Schema-Test/tmp/privatekey.json
          echo "test contents"
          cd tmp
          realpath privatekey.json
      
      - uses: actions/checkout@v3
      - uses: liquibase-github-actions/update@v4.29.1
        with:
          changelogFile: 'db/changelog/db.changelog-master.sql'
          url: 'jdbc:bigquery://https://googleapis.com/bigquery/v2:443;ProjectId=dev;OAuthType=0;OAuthServiceAcctEmail=my_acct@dev.iam.gserviceaccount.com;OAuthPvtKeyPath=/home/runner/work/BigQuery-Schema-Test/BigQuery-Schema-Test/tmp/privatekey.json'
          driver: 'com.simba.googlebigquery.jdbc.Driver'

I am now receiving the error:

Unexpected error running Liquibase: Connection could not be created to jdbc:bigquery://https://googleapis.com/bigquery/v2:443;ProjectId=dev;OAuthType=0;OAuthServiceAcctEmail=my_account@dev.iam.gserviceaccount.com;OAuthPvtKeyPath=/home/runner/work/BigQuery-Schema-Test/BigQuery-Schema-Test/tmp/privatekey.json with driver com.simba.googlebigquery.jdbc.Driver. [Simba][BigQueryJDBCDriver](100004) HttpTransport IO error : /home/runner/work/BigQuery-Schema-Test/BigQuery-Schema-Test/tmp/privatekey.json.

Please note that I added the last 3 lines of the “Create Private Key File” step for debugging purposes, i.e. to verify that the private key did indeed exist where I thought it would. And I was able to verify its location. So I’m not sure why this error is occurring.