forked from martialonline/workflow-status
-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
39 lines (34 loc) · 1.29 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
name: "Workflow Status Action"
description: "Trigger events like notifications or alerts using the workflow status"
author: "David Boenig <martialonline>"
outputs:
status:
description: "Returns either success or failed as workflow status"
value: ${{ steps.workflow-status.outputs.status }}
runs:
using: "composite"
steps:
- id: workflow-status
run: |
url="${GITHUB_API_URL}/repos"
repo="${GITHUB_REPOSITORY}"
run_id="${GITHUB_RUN_ID}"
token="${{ github.token }}"
failure=$(curl -s -H "Authorization: token ${token}" "${url}/${repo}/actions/runs/${run_id}/jobs?per_page=100" | \
jq -r '.jobs[] | select(.status == "completed" and .conclusion == "failure").conclusion' | \
wc -l)
cancelled=$(curl -s -H "Authorization: token ${token}" "${url}/${repo}/actions/runs/${run_id}/jobs?per_page=100" | \
jq -r '.jobs[] | select(.status == "completed" and .conclusion == "cancelled").conclusion' | \
wc -l)
if [ "${failure}" -gt 0 ]; then
status="failure"
elif [ "${cancelled}" -gt 0 ]; then
status="cancelled"
else
status="success"
fi
echo "status=${status}" >> $GITHUB_OUTPUT
shell: bash
branding:
icon: check-square
color: gray-dark