diff --git a/.github/workflows/draw-zmk.yml b/.github/workflows/draw-zmk.yml index be8d089..e33dc07 100644 --- a/.github/workflows/draw-zmk.yml +++ b/.github/workflows/draw-zmk.yml @@ -49,11 +49,26 @@ on: default: '' required: false type: string + destination: + description: 'Add the output files to a commit, as artifacts or both, values: `commit`, `artifact`, `both`' + default: 'commit' + required: false + type: string + artifact_name: + description: 'Name of the produced artifact containing SVG and YAML outputs. Ignored if `destination` is `commit`.' + default: 'drawings' + required: false + type: string + outputs: + drawings: + description: 'Archive with keymap in YAML and drawing in SVG formats' + value: ${{ jobs.draw.outputs.drawings }} jobs: draw: runs-on: ubuntu-latest - + outputs: + drawings: ${{ steps.artifact-upload-step.outputs.artifact-id }} steps: - name: Checkout uses: actions/checkout@v4 @@ -75,6 +90,7 @@ jobs: run: python3 -m pip install "git+https://github.com/caksoylar/keymap-drawer.git@${{ inputs.install_branch }}" - name: Draw keymaps + id: draw run: | get_args() { local keyboard=$2 @@ -89,6 +105,7 @@ jobs: done } + declare -a DRAWINGS mkdir -p "${{ inputs.output_folder }}" config_path="${{ inputs.config_path }}" @@ -111,15 +128,20 @@ jobs: keymap "${config_arg[@]}" parse -z "$keymap_file" $parse_args >"${{ inputs.output_folder }}/$keyboard.yaml" \ && keymap "${config_arg[@]}" draw "${{ inputs.output_folder }}/$keyboard.yaml" $draw_args >"${{ inputs.output_folder }}/$keyboard.svg" \ || echo "ERROR: parsing or drawing failed for $keyboard!" + DRAWINGS+=(\"${{ inputs.output_folder }}/$keyboard.yaml\" \"${{ inputs.output_folder }}/$keyboard.svg\") done - + IFS=',' + echo "DRAWINGS=[${DRAWINGS[*]}]" >> $GITHUB_OUTPUT + unset IFS + - name: Get last commit message id: last_commit_message - if: inputs.amend_commit == true + if: inputs.amend_commit == true && (inputs.destination == 'commit' || inputs.destination == 'both') run: | echo "msg=$(git log -1 --pretty=%s)" >> $GITHUB_OUTPUT - name: Commit updated images + if: ( inputs.destination == 'commit' || inputs.destination == 'both' ) uses: stefanzweifel/git-auto-commit-action@v5 with: file_pattern: '${{ inputs.output_folder }}/*.svg ${{ inputs.output_folder }}/*.yaml' @@ -132,3 +154,13 @@ jobs: commit_options: "${{ (inputs.amend_commit == true && '--amend --no-edit') || '' }}" push_options: "${{ (inputs.amend_commit == true && '--force-with-lease') || '' }}" skip_fetch: ${{ inputs.amend_commit == true }} + + - name: Artifact upload + id: artifact-upload-step + if: ( inputs.destination == 'artifact' || inputs.destination == 'both' ) + uses: actions/upload-artifact@v4 + with: + name: '${{ inputs.artifact_name }}' + path: | + ${{ join(fromJSON(steps.draw.outputs.DRAWINGS), ' + ') }}