@@ -27,11 +27,12 @@ lock="$dir/actions.lock"
2727fail=0
2828err () { printf ' ::error::%s\n' " $* " ; fail=1; }
2929
30- [ -f " $lock " ] || { err " actions lockfile missing: $lock " ; exit 1; }
30+ [[ -f " $lock " ] ] || { err " actions lockfile missing: $lock " ; exit 1; }
3131
3232# The actions a workflow file uses, normalised and sorted.
3333used () {
34- grep -E ' ^[[:space:]]*(-[[:space:]]*)?uses:' " $1 " \
34+ local file=" $1 "
35+ grep -E ' ^[[:space:]]*(-[[:space:]]*)?uses:' " $file " \
3536 | sed -E ' s/^[[:space:]]*(-[[:space:]]*)?uses:[[:space:]]*//; s/[[:space:]]+#.*$//; s/^["' \' ' ]//; s/["' \' ' ]$//; s/[[:space:]]+$//' \
3637 | grep -vE ' ^(\./|docker://)' \
3738 | grep -v ' /\.github/workflows/' \
@@ -41,7 +42,8 @@ used() {
4142
4243# The actions the lock lists for workflow path $1, sorted.
4344locked () {
44- awk -v wf=" '$1 ':" '
45+ local path=" $1 "
46+ awk -v wf=" '$path ':" '
4547 /^workflows:/ { inwf = 1; next }
4648 /^dependencies:/ { inwf = 0 }
4749 inwf && $1 == wf { on = 1; next }
@@ -55,25 +57,25 @@ deps=$(awk '/^dependencies:/ { d = 1; next } d && /^ '\''/ { k = $1; gsub(/['
5557
5658checked=0
5759for wf in " $dir " /* .yml " $dir " /* .yaml; do
58- [ -f " $wf " ] || continue
60+ [[ -f " $wf " ] ] || continue
5961 rel=" .github/workflows/$( basename " $wf " ) "
6062 checked=$(( checked + 1 ))
6163 u=$( used " $wf " )
6264 l=$( locked " $rel " )
6365 if ! grep -qF " '$rel ':" " $lock " ; then
64- [ -z " $u " ] || err " $rel uses actions but has no actions.lock entry: $( echo $u ) "
66+ [[ -z " $u " ] ] || err " $rel uses actions but has no actions.lock entry: $( echo $u ) "
6567 continue
6668 fi
6769 missing=$( comm -23 <( printf ' %s\n' " $u " | sed ' /^$/d' ) <( printf ' %s\n' " $l " | sed ' /^$/d' ) )
6870 stale=$( comm -13 <( printf ' %s\n' " $u " | sed ' /^$/d' ) <( printf ' %s\n' " $l " | sed ' /^$/d' ) )
69- [ -z " $missing " ] || err " $rel uses actions the lock does not list (regenerate actions.lock): $( echo $missing ) "
70- [ -z " $stale " ] || err " $rel : actions.lock lists actions the workflow no longer uses: $( echo $stale ) "
71+ [[ -z " $missing " ] ] || err " $rel uses actions the lock does not list (regenerate actions.lock): $( echo $missing ) "
72+ [[ -z " $stale " ] ] || err " $rel : actions.lock lists actions the workflow no longer uses: $( echo $stale ) "
7173 for a in $l ; do
7274 printf ' %s\n' " $deps " | grep -qxF " $a " || err " actions.lock has no dependencies entry for $a ($rel )"
7375 done
7476done
7577
76- if [ " $fail " -ne 0 ]; then
78+ if [[ " $fail " -ne 0 ] ]; then
7779 echo " actions.lock check FAILED: a mismatched workflow does not start (startup_failure, zero jobs)."
7880 exit 1
7981fi
0 commit comments