Generate Action #30
Workflow file for this run
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
name: Generate Action | |
on: | |
workflow_dispatch: | |
inputs: | |
liquibase-version: | |
description: 'Liquibase version' | |
required: true | |
default: '4.26.0' | |
type: string | |
workflow_call: | |
inputs: | |
liquibase-version: | |
description: 'Liquibase version' | |
required: true | |
default: '4.26.0' | |
type: string | |
permissions: | |
contents: write | |
pull-requests: write | |
jobs: | |
create-command-list: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Create feature branch | |
run: | | |
git checkout -b "feature/protobuf-${{ inputs.liquibase-version }}" | |
git branch --set-upstream-to=feature/protobuf-${{ inputs.liquibase-version }} | |
git pull | |
git push --set-upstream origin "feature/protobuf-${{ inputs.liquibase-version }}" | |
- 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 --experimental_allow_proto3_optional $COMMAND.proto | |
done | |
mkdir -p proto-commands | |
mv *.ts ./proto-commands | |
- name: Update liquibase binaries | |
run: | | |
wget -q https://github.com/liquibase/liquibase/releases/download/v${{ inputs.liquibase-version }}/liquibase-${{ inputs.liquibase-version }}.zip | |
unzip liquibase-${{ inputs.liquibase-version }}.zip -d liquibase | |
rm -rf ./bin/liquibase | |
mv liquibase ./bin | |
rm -rf liquibase-${{ inputs.liquibase-version }}.zip | |
- name: Configure git user | |
run: | | |
git config --global init.defaultBranch master | |
git config --global user.name "liquibot" | |
git config --global user.email "[email protected]" | |
- name: Push changes | |
continue-on-error: true | |
run: | | |
git pull | |
git add . | |
git commit -m "Generated protobuf files for liquibase version ${{ inputs.liquibase-version }}" | |
git push | |
env: | |
BOT_TOKEN: ${{ secrets.BOT_TOKEN }} | |
- name: Create Pull Request | |
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: feature/protobuf-${{ inputs.liquibase-version }} | |
base: master | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: commands-${{ inputs.liquibase-version }} | |
path: /proto/commands |