Introducing the Official Liquibase GitHub Action Plugin

Originally published at: Introducing the Official Liquibase GitHub Action Plugin | Liquibase.com

In honor of Hacktoberfest, Liquibase hosted a day-long internal Hackathon. My team’s challenge: make it easier to use Liquibase in Continuous Integration and Continuous Delivery (CI/CD) systems. Today, we’re happy to announce the official Liquibase plugin for GitHub Actions CI/CD

Official Liquibase GitHub Action

The official Liquibase GitHub Action follows GitHub best practices. If you’re familiar with GitHub Actions, you’ll be comfortable consuming it right away. If you’re new, I’ve got an example you can try.

This new plugin supports Liquibase commands that are most useful for automation, including: 

  • update
  • updateCount
  • tag
  • updateToTag
  • rollback
  • rollbackCount
  • rollbackToDate
  • updateSQL
  • futureRollbackSQL
  • status
  • history
  • diff

The Action also accepts required parameters such as database URL, credentials, and more. Prior to running a command, the Action will validate both the database credentials and the required command parameters are present.

How to use it

To use the official Liquibase GitHub Action in your project, add a new uses: tag to your Workflow YAML file that references liquibase/liquibase-github-action@v2. Modify the with: tag as appropriate to define the Liquibase command (operation) to execute and other parameters. The README in the Action’s repository provides two examples as well as information on required and optional inputs. 

Liquibase. GitHub. Action!

Want to see the plugin in action? We created an example repository just for you! The only prerequisite is some knowledge of Git. 

See the example YML

Here are the steps to use the example:

  1. Clone the liquibase-github-action-example repository into a GitHub repository of you own.
  2. Create a new git branch for your changes.
  3. Add a new changeset to example/changelogs/samplechangelog.h2.sql. For example:
--changeset your.name:4
--rollback DROP TABLE yourname;
CREATE TABLE yourname (
    id int primary key,
    name varchar(50) not null,
)
  1. Add, commit, and push your changes to your GitHub repository.
  2. See your commit trigger a build in GitHub and execute Liquibase update!

More Examples!

Want to learn about other ways to use Liquibase? We’ve included a folder full of examples that use other build systems, like Gradle or NodeJs. These examples don’t use the official GitHub Action (which is Docker-based) but allow for impressive automation.

Team CICD Plugins was led by Jake Newton and combined the mental might of Nathan Voxland, Derek Smart, Robert Reeves, Mike Olivas, Adeel Malik, Mike Runco, Dan Zentgraf, and Erzsebet Carmean.