2021-10-13 21:11:27 -07:00
name : 'Cache APT Packages'
description : 'Install APT based packages and cache them for future runs.'
author : awalsh128
2021-10-13 22:16:32 -07:00
branding :
icon : 'hard-drive'
color : 'green'
2021-10-13 21:11:27 -07:00
inputs :
packages :
description : 'Space delimited list of packages to install.'
required : true
default : ''
2021-10-16 11:34:03 -07:00
version :
description : 'Version will create a new cache and install packages.'
required : false
2021-10-21 15:44:19 -07:00
default : ''
refresh :
description : 'Option to refresh / upgrade the packages in the same cache.'
required : false
default : 'false'
2021-10-13 21:11:27 -07:00
outputs :
cache-hit :
description : 'A boolean value to indicate a cache was found for the packages requested.'
2021-10-16 21:17:41 -07:00
# This compound expression is needed because lhs can be empty.
# Need to output true and false instead of true and nothing.
2021-10-16 13:16:36 -07:00
value : ${{ steps.load-cache.outputs.cache-hit || false }}
2021-10-21 15:44:19 -07:00
package_version_list :
description : 'The packages and versions that are installed as a comma delimited list with colon delimit on the package version (i.e. <package>:<version,<package>:<version>).'
value : ${{ steps.get-package-versions.outputs.package_version_list }}
2021-10-13 21:11:27 -07:00
runs :
using : "composite"
steps :
- name : Validate Packages
2021-10-16 22:37:18 -07:00
run : ${{ github.action_path }}/validate_pkgs.sh "${{ inputs.version }}" ${{ inputs.packages }}
2021-10-16 10:54:31 -07:00
shell : bash
2021-10-13 21:11:27 -07:00
- name : Create Cache Key
2021-10-16 22:02:56 -07:00
run : |
2021-10-16 22:46:41 -07:00
${{ github.action_path }}/create_cache_key.sh "${{ inputs.version }})" ${{ inputs.packages }}
2021-10-13 21:11:27 -07:00
shell : bash
- name : Load Package Cache
2021-10-16 13:10:59 -07:00
id : load-cache
2021-10-13 21:11:27 -07:00
uses : actions/cache@v2
with :
path : ~/cache-apt-pkgs
2021-10-16 22:02:56 -07:00
key : cache-apt-pkgs_${{ env.CACHE_KEY }}
2021-10-13 21:11:27 -07:00
2021-10-16 11:15:06 -07:00
- name : Load Packages
2021-10-21 15:44:19 -07:00
run : |
if [ ! ${{ steps.load-cache.outputs.cache-hit }} ] || [ ${{ inputs.refresh }} ]; then
2021-10-16 11:25:42 -07:00
${{ github.action_path }}/install_and_cache_pkgs.sh ~/cache-apt-pkgs ${{ inputs.packages }}
2021-10-21 15:44:19 -07:00
else
${{ github.action_path }}/restore_pkgs.sh ~/cache-apt-pkgs /
2021-10-16 11:19:36 -07:00
fi
2021-10-13 21:11:27 -07:00
shell : bash
2021-10-21 15:44:19 -07:00
- name : Get Package Versions
id : get-package-versions
run : |
output=
for package in ${{ inputs.packages }}; do
output=$output,$package:$(dpkg -s xdot | grep Version | awk '{print $2}')
done
2021-10-21 15:54:16 -07:00
echo '::set-output name=package_version_list::output'
2021-10-21 15:44:19 -07:00
shell : bash