Merge pull request #8 from awalsh128/staging

Merge fixes and new features.
This commit is contained in:
Andrew Walsh 2021-10-21 17:08:27 -07:00 committed by GitHub
commit 89dc8d2e9e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 14 deletions

View file

@ -62,7 +62,7 @@ runs:
run: |
output=
for package in ${{ inputs.packages }}; do
output=$output,$package:$(dpkg -s xdot | grep Version | awk '{print $2}')
output=$output,$package:$(dpkg -s $package | grep Version | awk '{print $2}')
done
::set-output name=package_version_list::output
echo '::set-output name=package_version_list::output'
shell: bash

View file

@ -6,16 +6,18 @@ set -e
version=$1
packages=${@:2}
echo "* Creating cache key..."
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' ' ')
echo "* Normalized package list is '$normalized_list'."
echo "::debug::Normalized package list is '$normalized_list'."
value=$(echo $normalized_list @ $version)
echo "* Value to hash is '$value'."
echo "::debug::Value to hash is '$value'."
key=$(echo $value | md5sum | /bin/cut -f1 -d' ')
echo "* Value hashed as '$key'."
echo "::debug::Value hashed as '$key'."
echo "::endgroup::"
echo "CACHE_KEY=$key" >> $GITHUB_ENV

View file

@ -3,28 +3,27 @@
version=$1
packages=${@:2}
echo -n "* Validating action arguments... ";
echo "::group::Validate Action Arguments";
echo $version | grep -o " " > /dev/null
if [ $? -eq 0 ]; then
echo "aborted."
echo "* Version value '$version' cannot contain spaces." >&2
echo "::error::Aborted. Version value '$version' cannot contain spaces." >&2
exit 1
fi
echo "::debug::Version '$version' is valid."
if [ "$packages" == "" ]; then
echo "aborted."
echo "* Packages argument cannot be empty." >&2
echo "::error::Aborted. Packages argument cannot be empty." >&2
exit 2
fi
for package in $packages; do
apt-cache search ^$package$ | grep $package > /dev/null
if [ $? -ne 0 ]; then
echo "aborted."
echo "* Package '$package' not found." >&2
echo "::error::Aborted. Package '$package' not found." >&2
exit 3
fi
done
echo "::debug::Packages '$packages' are valid."
echo "done."
echo "::endgroup::"