cache-apt-pkgs-action/action.yml
Andrew Walsh 51678ad913
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 76128c60a1

* 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-23 22:24:00 -08:00

81 lines
3.2 KiB
YAML

name: 'Cache APT Packages'
description: 'Install APT based packages and cache them for future runs.'
author: awalsh128
branding:
icon: 'hard-drive'
color: 'green'
inputs:
packages:
description: 'Space delimited list of packages to install.'
required: true
default: ''
version:
description: 'Version of cache to load. Each version will have its own cache. Note, all characters except spaces are allowed.'
required: false
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'
refresh:
description: 'OBSOLETE, use version instead.'
debug:
description: 'Enable debugging when there are issues with action. Minor performance penalty.'
required: false
default: 'false'
outputs:
cache-hit:
description: 'A boolean value to indicate a cache was found for the packages requested.'
# This compound expression is needed because lhs can be empty.
# Need to output true and false instead of true and nothing.
value: ${{ steps.load-cache.outputs.cache-hit || false }}
package-version-list:
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>).'
value: ${{ steps.post-cache.outputs.all-package-version-list }}
runs:
using: "composite"
steps:
- id: pre-cache
run: |
${{ github.action_path }}/pre_cache_action.sh \
~/cache-apt-pkgs \
"${{ inputs.version }}" \
"${{ inputs.execute_install_scripts }}" \
"${{ inputs.debug }}" \
${{ inputs.packages }}
echo "CACHE_KEY=$(cat ~/cache-apt-pkgs/cache_key.md5)" >> $GITHUB_ENV
shell: bash
- id: load-cache
uses: actions/cache@v3
with:
path: ~/cache-apt-pkgs
key: cache-apt-pkgs_${{ env.CACHE_KEY }}
- id: post-cache
run: |
${{ github.action_path }}/post_cache_action.sh \
~/cache-apt-pkgs \
/ \
"${{ steps.load-cache.outputs.cache-hit }}" \
"${{ inputs.execute_install_scripts }}" \
"${{ inputs.debug }}" \
${{ inputs.packages }}
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
shell: bash
- 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