-
Notifications
You must be signed in to change notification settings - Fork 13
/
gha-steps.bash
23 lines (21 loc) · 1.01 KB
/
gha-steps.bash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/bash
function gha_steps() {(
local workspace=$(dirname $BASH_SOURCE)
PATH=$PATH:bin
yaml2json < $workspace/.github/workflows/CompileWindows.yml | jq -r '.jobs[].steps|to_entries[]|select(.value.name and ((.value.name//"")|startswith("~")|not))|.value.name+" # "+(.key|tostring)'
)}
function gha_step() {(
local workspace=$(dirname $BASH_SOURCE)
PATH=$PATH:bin
if [[ $# == 0 ]] ; then
gha_steps
return
fi
if [[ "$1" =~ ^[0-9a-f][0-9a-f][0-9a-f]$ ]]; then
yaml2json < $workspace/.github/workflows/CompileWindows.yml | jq -r --arg prefix "$1" '.jobs[].steps[]|select((.name//"")|startswith($prefix))|"# "+.name+"\n"+(.with.run//.run)'
elif [[ "$1" =~ ^[0-9]+$ ]]; then
yaml2json < $workspace/.github/workflows/CompileWindows.yml | jq -r --argjson name "$1" '.jobs[].steps[$name]|"# "+.name+"\n"+(.with.run//.run)'
else
yaml2json < $workspace/.github/workflows/CompileWindows.yml | jq -r --arg name "$1" '.jobs[].steps[]|select(.name==$name)|"# "+.name+"\n"+(.with.run//.run)'
fi
)}