cache-apt-pkgs-action/create_cache_key.sh

23 lines
582 B
Bash
Raw Normal View History

#!/bin/bash
# Fail on any error.
set -e
version=$1
packages=${@:2}
2021-10-21 22:54:29 +00:00
echo "::group::Create Cache Key"
# Remove package delimiters, sort (requires newline) and then convert back to inline list.
normalized_list=$(echo $packages | sed 's/[\s,]+/ /g' | tr ' ' '\n' | sort | tr '\n' ' ')
2021-10-21 22:54:29 +00:00
echo "::debug::Normalized package list is '$normalized_list'."
value=$(echo $normalized_list @ $version)
2021-10-21 22:54:29 +00:00
echo "::debug::Value to hash is '$value'."
key=$(echo $value | md5sum | /bin/cut -f1 -d' ')
2021-10-21 22:54:29 +00:00
echo "::debug::Value hashed as '$key'."
echo "::endgroup::"
2021-10-17 05:46:41 +00:00
echo "CACHE_KEY=$key" >> $GITHUB_ENV