add action outputs

This commit is contained in:
Emil Lerch 2023-03-27 23:09:02 -07:00
parent 51fa6f716f
commit 014b12e7fb
Signed by: lobo
GPG Key ID: A7B62D657EF764F8

View File

@ -2,11 +2,13 @@
dir="$(dirname "${INPUT_FILES}")" dir="$(dirname "${INPUT_FILES}")"
glob="$(basename "${INPUT_FILES}")" glob="$(basename "${INPUT_FILES}")"
# Pass these through sort so we can have deterministic output indexing
if [ "${glob}" = "**" ]; then if [ "${glob}" = "**" ]; then
all_files="$(find "$dir" -type f)" all_files="$(find "$dir" -type f |sort)"
else else
all_files="$(find "$dir" -maxdepth 1 -name "${glob}")" all_files="$(find "$dir" -maxdepth 1 -name "${glob}" |sort)"
fi fi
i=0
while IFS= read -r f; do while IFS= read -r f; do
sign_dir="$(dirname "$f")" sign_dir="$(dirname "$f")"
sign_file="$(basename "$f")" sign_file="$(basename "$f")"
@ -35,8 +37,13 @@ while IFS= read -r f; do
echo "Fetching key from ${INPUT_PUBLIC_KEY}" echo "Fetching key from ${INPUT_PUBLIC_KEY}"
curl -sLo /tmp/public_key "${INPUT_PUBLIC_KEY}" curl -sLo /tmp/public_key "${INPUT_PUBLIC_KEY}"
ec=$?; if [ $ec -ne 0 ]; then exit $ec; fi ec=$?; if [ $ec -ne 0 ]; then exit $ec; fi
rekor upload --artifact "$f" --signature "${dest_sig}" --pki-format x509 --public-key /tmp/public_key output=$(rekor upload --artifact "$f" --signature "${dest_sig}" --pki-format x509 --public-key /tmp/public_key)
ec=$?; if [ $ec -ne 0 ]; then exit $ec; fi ec=$?; echo "$output"; if [ $ec -ne 0 ]; then exit $ec; fi
echo "INDEX_${i}=$(echo "$output"|cut -d, -f1|cut -d\ -f5)" >> "${GITHUB_OUTPUT}"
echo "URL_${i}=$(echo "$output"|cut -d: -f2-|cut -d\ -f2)" >> "${GITHUB_OUTPUT}"
echo "SOURCE_${i}=${f}" >> "${GITHUB_OUTPUT}"
echo "SIG_${i}=${dest_sig}" >> "${GITHUB_OUTPUT}"
i=$((i+1))
fi fi
done <<ALLFILES_INPUT done <<ALLFILES_INPUT
$all_files $all_files