mirror of
https://github.com/awalsh128/cache-apt-pkgs-action.git
synced 2024-12-22 18:55:30 +00:00
Add better messaging.
This commit is contained in:
parent
9512f95182
commit
ca95c0de72
|
@ -9,27 +9,35 @@ cache_dir=$1
|
|||
packages="${@:2}"
|
||||
|
||||
package_count=$(echo $packages | wc -w)
|
||||
echo "* Clean installing $package_count packages..."
|
||||
echo "::debug::Clean installing $package_count packages..."
|
||||
for package in $packages; do
|
||||
echo " - $package"
|
||||
echo "::debug::- $package"
|
||||
done
|
||||
echo "::endgroup::"
|
||||
|
||||
mkdir -p $cache_dir
|
||||
echo "* Updating APT package list and get the latest information..."
|
||||
|
||||
echo "::group::Update APT Package List"
|
||||
sudo apt-get update
|
||||
echo "::endgroup::"
|
||||
|
||||
for package in $packages; do
|
||||
cache_filepath=$cache_dir/$package.tar.gz
|
||||
|
||||
echo "* Clean installing $package... "
|
||||
echo "::group::Clean install $package"
|
||||
sudo apt-get --yes install $package
|
||||
echo "::endgroup::"
|
||||
|
||||
echo "* Caching $package to $cache_filepath..."
|
||||
echo "::group::Caching $package to $cache_filepath"
|
||||
# Pipe all package files (no folders) to Tar.
|
||||
dpkg -L $package |
|
||||
while IFS= read -r f; do
|
||||
if test -f $f; then echo $f; fi;
|
||||
done |
|
||||
xargs tar -czf $cache_filepath -C /
|
||||
echo "::endgroup::"
|
||||
done
|
||||
|
||||
echo "Action complete. $(echo $packages | wc -w) package(s) installed and cached."
|
||||
echo "::group::Finished"
|
||||
echo "::debug::$(echo $packages | wc -w) package(s) installed and cached."
|
||||
echo "::endgroup::"
|
||||
|
|
|
@ -13,18 +13,24 @@ packages="${@:3}"
|
|||
|
||||
cache_filenames=$(ls -1 $cache_dir | sort)
|
||||
cache_filename_count=$(echo $cache_filenames | wc -w)
|
||||
echo "* Found $cache_filename_count files in cache..."
|
||||
for cache_filename in $cache_filenames; do
|
||||
echo " - $cache_filename"
|
||||
done
|
||||
|
||||
echo "::group::Found $cache_filename_count files in cache."
|
||||
for cache_filename in $cache_filenames; do
|
||||
echo "::debug::$cache_filename"
|
||||
done
|
||||
echo "::endgroup::"
|
||||
|
||||
echo "::group::Package Restore"
|
||||
for package in $packages; do
|
||||
cache_filepath=$cache_dir/$package.tar.gz
|
||||
echo "* Restoring package $package ($cache_filepath) from cache... "
|
||||
echo "::debug::Restoring package $package ($cache_filepath) from cache... "
|
||||
sudo tar -xf $cache_filepath -C $cache_restore_root
|
||||
# Upgrade the install from last state.
|
||||
# TODO(awalsh128) Add versioning to cache key creation.
|
||||
sudo apt-get --yes --only-upgrade install $package
|
||||
done
|
||||
echo "::endgroup::"
|
||||
|
||||
echo "Action complete. $cache_filename_count package(s) restored."
|
||||
echo "::group::Finished"
|
||||
echo "::debug::Action complete. $cache_filename_count package(s) restored."
|
||||
echo "::endgroup::"
|
Loading…
Reference in a new issue