Skip to content

Generate Action

Generate Action #19

Workflow file for this run

name: Generate Action
on:
workflow_dispatch:
inputs:
liquibase-version:
description: 'Liquibase version'
required: true
default: '4.26.0'
permissions:
contents: write
pull-requests: write
jobs:
create-command-list:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install protoc and npm
run: |
sudo apt-get install -y protobuf-compiler npm
npm install proto ts-proto
- name: Build liquibase-protobuf-generator
run: docker build -t liquibase-protobuf-generator:${{ inputs.liquibase-version }} . --build-arg VERSION=${{ inputs.liquibase-version }}
- name: Generate liquibase command list
run: docker run --rm -v $(pwd):/proto liquibase-protobuf-generator:${{ inputs.liquibase-version }} --output-file=commands.json list-commands
- name: Iterate over commands and execute Docker command
run: |
COMMANDS=$(cat commands.json | jq -r '.[]')
IFS=$'\n'
for command in $COMMANDS; do
docker run --rm -v $(pwd):/proto liquibase-protobuf-generator:${{ inputs.liquibase-version }} generate-protobuf --target-command="$command" --output-dir /proto
COMMAND="${command//-/_}"
COMMAND="${COMMAND/ /_}"
protoc --plugin=./node_modules/.bin/protoc-gen-ts_proto --ts_proto_out=. --ts_proto_opt=exportCommonSymbols=false $COMMAND.proto
done
mkdir -p proto-commands
mv *.ts ./proto-commands
- name: Configure git user
if: github.ref != 'refs/heads/master'
run: |
git config --global init.defaultBranch master
git config --global user.name "liquibot"
git config --global user.email "[email protected]"
- name: Push changes
if: github.ref != 'refs/heads/master'
continue-on-error: true
run: |
git pull
git add proto-commands
git commit -m "Generated protobuf files for liquibase version ${{ inputs.liquibase-version }}"
git push
env:
BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
- name: Create Pull Request
if: github.ref != 'refs/heads/master'
uses: peter-evans/create-pull-request@v6
with:
commit-message: Auto Pull Request for protobuf files [liquibase ${{ inputs.liquibase-version }}]
title: Auto Pull Request for protobuf files [liquibase ${{ inputs.liquibase-version }}]
body: Auto Pull Request for protobuf files [liquibase ${{ inputs.liquibase-version }}]
branch: ${{ github.ref }}
base: master
- uses: actions/upload-artifact@v3
with:
name: commands-${{ inputs.liquibase-version }}
path: /proto/commands