Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an artifact as destination option for using in subsequent jobs #72

Merged
merged 19 commits into from
Feb 18, 2024
Merged
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 34 additions & 2 deletions .github/workflows/draw-zmk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
artifactname:
description: 'Define the name the drawings are stored as an artifact'
michaelrommel marked this conversation as resolved.
Show resolved Hide resolved
default: 'drawings'
required: false
type: string
outputs:
drawings-id:
description: 'Archive with keymap in yaml and drawing in svg formats'
michaelrommel marked this conversation as resolved.
Show resolved Hide resolved
value: ${{ jobs.draw.outputs.drawings-id }}

jobs:
draw:
runs-on: ubuntu-latest

outputs:
drawings-id: ${{ steps.artifact-upload-step.outputs.artifact-id }}
michaelrommel marked this conversation as resolved.
Show resolved Hide resolved
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -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
Expand All @@ -93,6 +109,7 @@ jobs:

config_path="${{ inputs.config_path }}"
[ -e "$config_path" ] && config_arg=(-c "$config_path") || config_arg=()
FIRST=1
for keymap_file in ${{ inputs.keymap_patterns }}; do
keyboard=$(basename -s .keymap "$keymap_file")
echo "INFO: drawing for $keyboard"
Expand All @@ -111,15 +128,21 @@ 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!"
if [[ ${FIRST} -ne 1 ]]; then
OUTPUTS="${OUTPUTS},"
fi
OUTPUTS="${OUTPUTS}\"${{ inputs.output_folder }}/$keyboard.yaml\",\"${{ inputs.output_folder }}/$keyboard.svg\""
done
echo "OUTPUTS=[${OUTPUTS}]" >> $GITHUB_OUTPUT
caksoylar marked this conversation as resolved.
Show resolved Hide resolved

- 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'
Expand All @@ -132,3 +155,12 @@ 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
uses: actions/upload-artifact@v4
michaelrommel marked this conversation as resolved.
Show resolved Hide resolved
with:
name: '${{ inputs.artifactname }}'
path: |
${{ join(fromJSON(steps.draw.outputs.OUTPUTS), '
') }}