Skip to content
New issue

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

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

Already on GitHub? # to your account

feat: option to fail GH Action on error #74

Merged
merged 1 commit into from
Mar 14, 2024
Merged
Changes from all 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
15 changes: 14 additions & 1 deletion .github/workflows/draw-zmk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ on:
default: 'drawings'
required: false
type: string
fail_on_error:
description: 'Fail the action if an error occurs during parse/draw'
default: false
required: false
type: boolean
outputs:
drawings:
description: 'Archive with keymap in YAML and drawing in SVG formats'
Expand Down Expand Up @@ -106,6 +111,7 @@ jobs:
}

declare -a DRAWINGS
error_occurred=0
mkdir -p "${{ inputs.output_folder }}"

config_path="${{ inputs.config_path }}"
Expand All @@ -127,13 +133,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!"
|| {
echo "ERROR: parsing or drawing failed for $keyboard!"
error_occurred=1
}
DRAWINGS+=(\"${{ inputs.output_folder }}/$keyboard.yaml\" \"${{ inputs.output_folder }}/$keyboard.svg\")
done
IFS=','
echo "DRAWINGS=[${DRAWINGS[*]}]" >> $GITHUB_OUTPUT
unset IFS

if [ "${{ inputs.fail_on_error }}" == "true" ] && [ $error_occurred -eq 1 ]; then
exit 1
fi

- name: Get last commit message
id: last_commit_message
if: inputs.amend_commit == true && (inputs.destination == 'commit' || inputs.destination == 'both')
Expand Down