Skip to content
Open
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
7 changes: 5 additions & 2 deletions .ci.ghactions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@

set -euo pipefail

# Keep the pipeline's while loop in this shell so status updates survive.
shopt -s lastpipe

declare -A seen
status=0

Expand All @@ -41,8 +44,8 @@ do
fi
seen["$action-$hash-$tag"]=1

if eval "$( curl -s -H "Accept: application/vnd.github+json" \
"https://api.github.com/repos/$action/commits/$tag" | jq -r '.sha == "'"$hash"'"' )"
if curl --fail --silent --show-error -H "Accept: application/vnd.github+json" \
"https://api.github.com/repos/$action/commits/$tag" | jq -e --arg hash "$hash" '.sha == $hash' >/dev/null
Comment on lines +47 to +48

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An alternative would be to avoid the GitHub API and jq by checking the remote tag with Git directly.

Suggested change
if curl --fail --silent --show-error -H "Accept: application/vnd.github+json" \
"https://api.github.com/repos/$action/commits/$tag" | jq -e --arg hash "$hash" '.sha == $hash' >/dev/null
if git ls-remote --exit-code "https://github.com/$action.git" \
"refs/tags/$tag" "refs/tags/$tag^{}" |
grep -q "^$hash[[:space:]]"

Let me know which approach you prefer.

then
printf "\e[1;32m%s: %s@%s == %s\e[m\n" "$w" "$action" "$tag" "$hash"
else
Expand Down