cache-apt-pkgs-action/action.yml
2021-10-21 15:44:19 -07:00

68 lines
2.3 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 will create a new cache and install packages.'
required: false
default: ''
refresh:
description: 'Option to refresh / upgrade the packages in the same cache.'
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 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 }}
runs:
using: "composite"
steps:
- name: Validate Packages
run: ${{ github.action_path }}/validate_pkgs.sh "${{ inputs.version }}" ${{ inputs.packages }}
shell: bash
- name: Create Cache Key
run: |
${{ github.action_path }}/create_cache_key.sh "${{ inputs.version }})" ${{ inputs.packages }}
shell: bash
- name: Load Package Cache
id: load-cache
uses: actions/cache@v2
with:
path: ~/cache-apt-pkgs
key: cache-apt-pkgs_${{ env.CACHE_KEY }}
- name: Load Packages
run: |
if [ ! ${{ steps.load-cache.outputs.cache-hit }} ] || [ ${{ inputs.refresh }} ]; then
${{ github.action_path }}/install_and_cache_pkgs.sh ~/cache-apt-pkgs ${{ inputs.packages }}
else
${{ github.action_path }}/restore_pkgs.sh ~/cache-apt-pkgs /
fi
shell: bash
- 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
::set-output name=package_version_list::output
shell: bash