2021-10-14 04:11:27 +00:00
name : 'Cache APT Packages'
description : 'Install APT based packages and cache them for future runs.'
author : awalsh128
2021-10-14 05:16:32 +00:00
branding :
icon : 'hard-drive'
color : 'green'
2021-10-14 04:11:27 +00:00
inputs :
packages :
description : 'Space delimited list of packages to install.'
required : true
default : ''
2021-10-16 18:34:03 +00:00
version :
2022-11-24 06:24:00 +00:00
description : 'Version of cache to load. Each version will have its own cache. Note, all characters except spaces are allowed.'
2021-10-16 18:34:03 +00:00
required : false
2022-11-24 06:24:00 +00:00
default : ''
execute_install_scripts :
description : 'Execute Debian package pre and post install script upon restore. See README.md caveats for more information.'
required : false
default : 'false'
2021-10-21 22:44:19 +00:00
refresh :
2022-11-24 06:24:00 +00:00
description : 'OBSOLETE, use version instead.'
debug :
description : 'Enable debugging when there are issues with action. Minor performance penalty.'
2021-10-21 22:44:19 +00:00
required : false
default : 'false'
2021-10-14 04:11:27 +00:00
outputs :
cache-hit :
description : 'A boolean value to indicate a cache was found for the packages requested.'
2021-10-17 04:17:41 +00: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 20:16:36 +00:00
value : ${{ steps.load-cache.outputs.cache-hit || false }}
2021-10-22 03:57:52 +00:00
package-version-list :
2022-07-20 03:42:48 +00:00
description : 'The main requested packages and versions that are installed. Represented as a comma delimited list with colon delimit on the package version (i.e. <package>:<version,<package>:<version>).'
value : ${{ steps.post-cache.outputs.package-version-list }}
all-package-version-list :
description : 'All the pulled in packages and versions, including dependencies, that are installed. Represented as a comma delimited list with colon delimit on the package version (i.e. <package>:<version,<package>:<version>).'
2022-07-15 23:14:30 +00:00
value : ${{ steps.post-cache.outputs.all-package-version-list }}
2021-10-14 04:11:27 +00:00
runs :
using : "composite"
steps :
2021-10-22 03:57:52 +00:00
- id : pre-cache
2021-10-17 05:02:56 +00:00
run : |
2022-12-08 06:11:01 +00:00
${GITHUB_ACTION_PATH}/pre_cache_action.sh \
2021-10-22 04:13:01 +00:00
~/cache-apt-pkgs \
"${{ inputs.version }}" \
2022-11-24 06:24:00 +00:00
"${{ inputs.execute_install_scripts }}" \
"${{ inputs.debug }}" \
2021-10-22 04:13:01 +00:00
${{ inputs.packages }}
2021-10-22 03:57:52 +00:00
echo "CACHE_KEY=$(cat ~/cache-apt-pkgs/cache_key.md5)" >> $GITHUB_ENV
2021-10-14 04:11:27 +00:00
shell : bash
2021-10-22 03:57:52 +00:00
- id : load-cache
2022-07-20 03:42:48 +00:00
uses : actions/cache@v3
2021-10-14 04:11:27 +00:00
with :
path : ~/cache-apt-pkgs
2021-10-17 05:02:56 +00:00
key : cache-apt-pkgs_${{ env.CACHE_KEY }}
2021-10-14 04:11:27 +00:00
2021-10-22 03:57:52 +00:00
- id : post-cache
2021-10-21 22:44:19 +00:00
run : |
2022-12-08 06:11:01 +00:00
${GITHUB_ACTION_PATH}/post_cache_action.sh \
2021-10-22 04:30:33 +00:00
~/cache-apt-pkgs \
/ \
2021-10-22 04:03:30 +00:00
"${{ steps.load-cache.outputs.cache-hit }}" \
2022-11-24 06:24:00 +00:00
"${{ inputs.execute_install_scripts }}" \
"${{ inputs.debug }}" \
2021-10-22 04:03:30 +00:00
${{ inputs.packages }}
2022-07-20 03:42:48 +00:00
function create_list { local list=$(cat ~/cache-apt-pkgs/manifest_${1}.log | tr '\n' ','); echo ${list:0:-1}; };
2022-10-30 18:49:55 +00:00
echo "package-version-list=$(create_list main)" >> $GITHUB_OUTPUT
echo "all-package-version-list=$(create_list all)" >> $GITHUB_OUTPUT
2021-10-21 22:44:19 +00:00
shell : bash
2022-11-24 06:24:00 +00:00
- id : upload-logs
if : ${{ inputs.debug }} == "true"
uses : actions/upload-artifact@v3
with :
name : cache-apt-pkgs-logs%${{ inputs.packages }}%${{ inputs.version }}
path : ~/cache-apt-pkgs/*.log