2021-10-13 21:11:27 -07:00
|
|
|
#!/bin/bash
|
|
|
|
|
2021-10-16 22:37:18 -07:00
|
|
|
version=$1
|
|
|
|
packages=${@:2}
|
2021-10-13 21:11:27 -07:00
|
|
|
|
2021-10-21 15:58:33 -07:00
|
|
|
echo "::group::Validate Action Arguments";
|
2021-10-16 22:37:18 -07:00
|
|
|
|
|
|
|
echo $version | grep -o " " > /dev/null
|
2021-10-16 22:39:43 -07:00
|
|
|
if [ $? -eq 0 ]; then
|
2021-10-21 15:54:29 -07:00
|
|
|
echo "::error::Aborted. Version value '$version' cannot contain spaces." >&2
|
2021-10-16 22:41:42 -07:00
|
|
|
exit 1
|
|
|
|
fi
|
2021-10-16 22:37:18 -07:00
|
|
|
|
2021-10-13 21:11:27 -07:00
|
|
|
if [ "$packages" == "" ]; then
|
2021-10-21 15:54:29 -07:00
|
|
|
echo "::error::Aborted. Packages argument cannot be empty." >&2
|
2021-10-16 22:37:18 -07:00
|
|
|
exit 2
|
2021-10-13 21:11:27 -07:00
|
|
|
fi
|
2021-10-16 22:37:18 -07:00
|
|
|
|
2021-10-13 21:11:27 -07:00
|
|
|
for package in $packages; do
|
|
|
|
apt-cache search ^$package$ | grep $package > /dev/null
|
|
|
|
if [ $? -ne 0 ]; then
|
2021-10-21 15:54:29 -07:00
|
|
|
echo "::error::Aborted. Package '$package' not found." >&2
|
2021-10-16 22:37:18 -07:00
|
|
|
exit 3
|
2021-10-13 21:11:27 -07:00
|
|
|
fi
|
|
|
|
done
|
2021-10-16 22:37:18 -07:00
|
|
|
|
2021-10-21 15:54:29 -07:00
|
|
|
echo "::endgroup::"
|