cache-apt-pkgs-action/action.yml

104 lines
4 KiB
YAML
Raw Normal View History

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:
2023-03-24 11:50:32 +00:00
description: 'Space delimited list of packages to install. Version can be specified optionally using APT command syntax of <name>=<version> (e.g. xdot=1.2-2).'
2021-10-14 04:11:27 +00:00
required: true
default: ''
2021-10-16 18:34:03 +00:00
version:
Execute installation scripts feature, debug mode, and permission denied fix. (#65) * Execute installation scripts and debug mode features. (#64) * Provide the ability to call Debian package manager installation scripts (i.e. `*.[preinst, postinst]`). * Introduce a debug mode that runs the scripts in verbose mode and uploads the logs for retrieval. * Updated README to reflect new features and provided more info on how to use the action versions. * Dev (#66) * Fix permission denied error. * Fix permission denied error. (#51) * Remove compression from file caching. (#53) * Draft of postinst support from issue #44. * Remove bad option. * Removed extraneous line. * Cover no packages edge case when writing manifest. * Fix postinst bugs and add docs to lib. * Made cache directory variable and more refinements to postinst. * Update deprecated option. https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/ * Rollback accidental commit of new postinst feature. * Minor edit ands full install script execution FR. * Fix execute_install_scripts message to show the right param name. * Fix param check. * Minor fix to doc. * Upload action logs for debugging. * Make artifact names unique. * Add debug option. * Update description. * Debug package list issue. * Rollback https://github.com/awalsh128/cache-apt-pkgs-action/commit/76128c60a11c33c0b900402e8068a60c986affd9 * Revert outputs set behavior to see if it fixes outputs issue in dev. * Restore updated outputs behavior. So strange it is working when I revert. * Fix bugs in install script execution. * Add error suppression on file testing. * Debug feature. * Link to the issue that started the postinst troubleshooting. * Describe action version usage. * Fix package outputs command.
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
Execute installation scripts feature, debug mode, and permission denied fix. (#65) * Execute installation scripts and debug mode features. (#64) * Provide the ability to call Debian package manager installation scripts (i.e. `*.[preinst, postinst]`). * Introduce a debug mode that runs the scripts in verbose mode and uploads the logs for retrieval. * Updated README to reflect new features and provided more info on how to use the action versions. * Dev (#66) * Fix permission denied error. * Fix permission denied error. (#51) * Remove compression from file caching. (#53) * Draft of postinst support from issue #44. * Remove bad option. * Removed extraneous line. * Cover no packages edge case when writing manifest. * Fix postinst bugs and add docs to lib. * Made cache directory variable and more refinements to postinst. * Update deprecated option. https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/ * Rollback accidental commit of new postinst feature. * Minor edit ands full install script execution FR. * Fix execute_install_scripts message to show the right param name. * Fix param check. * Minor fix to doc. * Upload action logs for debugging. * Make artifact names unique. * Add debug option. * Update description. * Debug package list issue. * Rollback https://github.com/awalsh128/cache-apt-pkgs-action/commit/76128c60a11c33c0b900402e8068a60c986affd9 * Revert outputs set behavior to see if it fixes outputs issue in dev. * Restore updated outputs behavior. So strange it is working when I revert. * Fix bugs in install script execution. * Add error suppression on file testing. * Debug feature. * Link to the issue that started the postinst troubleshooting. * Describe action version usage. * Fix package outputs command.
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:
description: 'OBSOLETE: Refresh is not used by the action, use version instead.'
deprecationMessage: 'Refresh is not used by the action, use version instead.'
Execute installation scripts feature, debug mode, and permission denied fix. (#65) * Execute installation scripts and debug mode features. (#64) * Provide the ability to call Debian package manager installation scripts (i.e. `*.[preinst, postinst]`). * Introduce a debug mode that runs the scripts in verbose mode and uploads the logs for retrieval. * Updated README to reflect new features and provided more info on how to use the action versions. * Dev (#66) * Fix permission denied error. * Fix permission denied error. (#51) * Remove compression from file caching. (#53) * Draft of postinst support from issue #44. * Remove bad option. * Removed extraneous line. * Cover no packages edge case when writing manifest. * Fix postinst bugs and add docs to lib. * Made cache directory variable and more refinements to postinst. * Update deprecated option. https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/ * Rollback accidental commit of new postinst feature. * Minor edit ands full install script execution FR. * Fix execute_install_scripts message to show the right param name. * Fix param check. * Minor fix to doc. * Upload action logs for debugging. * Make artifact names unique. * Add debug option. * Update description. * Debug package list issue. * Rollback https://github.com/awalsh128/cache-apt-pkgs-action/commit/76128c60a11c33c0b900402e8068a60c986affd9 * Revert outputs set behavior to see if it fixes outputs issue in dev. * Restore updated outputs behavior. So strange it is working when I revert. * Fix bugs in install script execution. * Add error suppression on file testing. * Debug feature. * Link to the issue that started the postinst troubleshooting. * Describe action version usage. * Fix package outputs command.
2022-11-24 06:24:00 +00:00
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 }}
package-version-list:
2023-03-24 11:50:32 +00:00
description: 'The main requested packages and versions that are installed. Represented as a comma delimited list with equals delimit on the package version (i.e. <package>:<version,<package>:<version>).'
2022-07-20 03:42:48 +00:00
value: ${{ steps.post-cache.outputs.package-version-list }}
all-package-version-list:
2023-03-24 11:50:32 +00:00
description: 'All the pulled in packages and versions, including dependencies, that are installed. Represented as a comma delimited list with equals 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:
- id: pre-cache
2021-10-17 05:02:56 +00:00
run: |
${GITHUB_ACTION_PATH}/pre_cache_action.sh \
~/cache-apt-pkgs \
"$VERSION" \
"$EXEC_INSTALL_SCRIPTS" \
"$DEBUG" \
"$PACKAGES"
echo "CACHE_KEY=$(cat ~/cache-apt-pkgs/cache_key.md5)" >> $GITHUB_ENV
2021-10-14 04:11:27 +00:00
shell: bash
env:
VERSION: "${{ inputs.version }}"
EXEC_INSTALL_SCRIPTS: "${{ inputs.execute_install_scripts }}"
DEBUG: "${{ inputs.debug }}"
PACKAGES: "${{ inputs.packages }}"
2021-10-14 04:11:27 +00:00
- id: load-cache
uses: actions/cache/restore@v4
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
- id: post-cache
2023-03-24 11:50:32 +00:00
run: |
${GITHUB_ACTION_PATH}/post_cache_action.sh \
2021-10-22 04:30:33 +00:00
~/cache-apt-pkgs \
/ \
"$CACHE_HIT" \
"$EXEC_INSTALL_SCRIPTS" \
"$DEBUG" \
"$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}; };
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
env:
CACHE_HIT: "${{ steps.load-cache.outputs.cache-hit }}"
EXEC_INSTALL_SCRIPTS: "${{ inputs.execute_install_scripts }}"
DEBUG: "${{ inputs.debug }}"
PACKAGES: "${{ inputs.packages }}"
Execute installation scripts feature, debug mode, and permission denied fix. (#65) * Execute installation scripts and debug mode features. (#64) * Provide the ability to call Debian package manager installation scripts (i.e. `*.[preinst, postinst]`). * Introduce a debug mode that runs the scripts in verbose mode and uploads the logs for retrieval. * Updated README to reflect new features and provided more info on how to use the action versions. * Dev (#66) * Fix permission denied error. * Fix permission denied error. (#51) * Remove compression from file caching. (#53) * Draft of postinst support from issue #44. * Remove bad option. * Removed extraneous line. * Cover no packages edge case when writing manifest. * Fix postinst bugs and add docs to lib. * Made cache directory variable and more refinements to postinst. * Update deprecated option. https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/ * Rollback accidental commit of new postinst feature. * Minor edit ands full install script execution FR. * Fix execute_install_scripts message to show the right param name. * Fix param check. * Minor fix to doc. * Upload action logs for debugging. * Make artifact names unique. * Add debug option. * Update description. * Debug package list issue. * Rollback https://github.com/awalsh128/cache-apt-pkgs-action/commit/76128c60a11c33c0b900402e8068a60c986affd9 * Revert outputs set behavior to see if it fixes outputs issue in dev. * Restore updated outputs behavior. So strange it is working when I revert. * Fix bugs in install script execution. * Add error suppression on file testing. * Debug feature. * Link to the issue that started the postinst troubleshooting. * Describe action version usage. * Fix package outputs command.
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_${{ env.CACHE_KEY }}
path: ~/cache-apt-pkgs/*.log
2023-03-06 14:56:37 +00:00
- id: save-cache
if: ${{ ! steps.load-cache.outputs.cache-hit }}
uses: actions/cache/save@v4
2023-03-06 14:56:37 +00:00
with:
path: ~/cache-apt-pkgs
key: ${{ steps.load-cache.outputs.cache-primary-key }}
- id: clean-cache
run: |
rm -rf ~/cache-apt-pkgs
shell: bash