Skip to content

Commit 6522bb7

Browse files
GHA-150 Refactor job parsing to use jq for improved JSON handling (#65)
1 parent 9d383d1 commit 6522bb7

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

notify-slack/action.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,8 @@ runs:
2626
JOBS: ${{ inputs.jobs }}
2727
run: |
2828
echo "Checking Jobs: $JOBS"
29-
# Parse the provided jobs mapping string without relying on strict JSON. Extract keys where result == failure.
30-
# This handles inputs like: { build: { result: failure, outputs: {} }, qa_tests: { result: skipped, outputs: {} } }
31-
FAILED_JOBS=$(echo "$JOBS" | awk '
32-
/[[:alnum:]_.-]+:[[:space:]]*\{/{ key=$1; sub(/:$/, "", key) }
33-
/result[[:space:]]*:[[:space:]]*failure/{ fails=(fails?fails", ":"") key }
34-
END{ print fails }
35-
')
29+
# Parse the provided jobs JSON and extract keys where result == "failure".
30+
FAILED_JOBS=$(echo "$JOBS" | jq -r 'to_entries | map(select(.value.result == "failure") | .key) | join(", ")')
3631
echo "Failed Jobs: $FAILED_JOBS"
3732
echo "failed-jobs=$FAILED_JOBS" >> $GITHUB_OUTPUT
3833
- name: Vault Secrets

0 commit comments

Comments
 (0)