Run Hackolade CLI using Docker Compose on Github Actions #16
This file contains hidden or 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: Run Hackolade CLI using Docker Compose on Github Actions | |
on: | |
workflow_dispatch: | |
jobs: | |
run-hackolade-with-compose: | |
runs-on: ubuntu-latest | |
env: | |
# License key must be managed as a secret (Repository or Organization) | |
HACKOLADE_KEY: ${{ secrets.HACKOLADE_CONCURRENT_LICENSE_KEY }} | |
HACKOLADE_STUDIO_CLI_IMAGE: studio:latest | |
REPOSITORY_DIR_IN_CONTAINER: '/github/workspace/repository' | |
OUTPUT_DIR_IN_CONTAINER: '/home/hackolade/Documents/output' | |
DATA_VOLUMES_CONTAINER_NAME: hck-studio-cli-generated-data | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Build Hackolade Docker image | |
id: build-studio-cli-docker-image | |
run: | | |
docker build --no-cache --pull -t ${{ env.HACKOLADE_STUDIO_CLI_IMAGE }} . | |
- name: Create logs and output directories and data container | |
id: create-logs-and-output-directories | |
run: | | |
mkdir -p output | |
mkdir -p logs | |
docker container create --name ${{ env.DATA_VOLUMES_CONTAINER_NAME }} -v hackolade-studio-logs:/logs -v hackolade-studio-output:/output ${{ env.HACKOLADE_STUDIO_CLI_IMAGE }} | |
- name: Retrieve image identifier for GHA | |
id: retrieve-identifier-for-hackolade-studio-licensing | |
run: echo "identifier=$(docker compose run -i --rm --entrypoint show-computer-id.sh hackoladeStudioCLI)" >> $GITHUB_OUTPUT | |
- name: Validate concurrent license | |
id: validate-concurrent-hackolade-studio-license | |
run: | | |
docker compose run --rm hackoladeStudioCLI validatekey \ | |
--key "${{ env.HACKOLADE_KEY }}" \ | |
--identifier "github-actions-workflow-${{ steps.retrieve-identifier-for-hackolade-studio-licensing.outputs.identifier }}" | |
- name: Retrieve Hackolade logs of license validation | |
run: | | |
docker cp ${{ env.DATA_VOLUMES_CONTAINER_NAME }}:/logs/. ${PWD}/logs/logs-validate-license | |
- name: Generate Markdown documentation for travel.json example model | |
id: generate-md-doc-travel-model | |
run: | | |
# Working directory in container is set to REPOSITORY_DIR_IN_CONTAINER | |
docker compose run --rm hackoladeStudioCLI genDoc \ | |
--model=travel.json \ | |
--format=MD \ | |
--doc=${{ env.OUTPUT_DIR_IN_CONTAINER }}/travel.md | |
- name: Retrieve Hackolade logs of documentation generation | |
run: | | |
docker cp ${{ env.DATA_VOLUMES_CONTAINER_NAME }}:/logs/. ${PWD}/logs/logs-doc-generation | |
- name: FE - Generate jsonschema file for travel.json example model | |
id: generate-fe-jsonschema-for-travel-model | |
run: | | |
# Working directory in container is set to REPOSITORY_DIR_IN_CONTAINER | |
docker compose run --rm hackoladeStudioCLI forweng \ | |
--model=travel.json \ | |
--jsonschemacompliance full \ | |
--skipUndefinedLevel \ | |
--structuredpath false \ | |
--path ${{ env.OUTPUT_DIR_IN_CONTAINER }} \ | |
--outputtype jsonschema | |
- name: Retrieve Hackolade output files and logs from volumes | |
run: | | |
docker cp ${{ env.DATA_VOLUMES_CONTAINER_NAME }}:/output/. ${PWD}/output/. | |
docker cp ${{ env.DATA_VOLUMES_CONTAINER_NAME }}:/logs/. ${PWD}/logs/logs-fe-jsonschema-generation | |
- name: Tear down docker data | |
run: | | |
docker compose down -v | |
docker container rm ${{ env.DATA_VOLUMES_CONTAINER_NAME }} | |
- name: List generated artifacts and logs for user clarity | |
id: list-outputs-and-logs | |
run: | | |
ls -Rah ./output | |
ls -Rah ./logs | |
#https://github.com/actions/upload-artifact/tree/v4/?tab=readme-ov-file#zip-archives | |
- name: Upload logs to Github Artifacts | |
id: persist-logs | |
uses: actions/upload-artifact@v4.6.2 | |
with: | |
name: studio-cli-logs | |
path: ./logs | |
if-no-files-found: warn | |
retention-days: 5 | |
- name: Prepare generated artifacts | |
id: prepare-hackolade-studio-output | |
run: | | |
cp -ar ./output/. ./generated/ | |
# https://github.com/marketplace/actions/create-pull-request | |
- name: Open Pull Request with generated documentation | |
id: open-pr-with-updated-doc | |
uses: peter-evans/create-pull-request@v7 | |
with: | |
add-paths: ./generated | |
branch: update-documentation-and-jsonschema-travel-model | |
branch-suffix: timestamp | |
title: Update MD documentation and jsonschema sample for travel.json data model |