cache-apt-pkgs-action/action.yml
2021-10-16 13:10:59 -07:00

49 lines
1.5 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: ''
outputs:
cache-hit:
description: 'A boolean value to indicate a cache was found for the packages requested.'
value: ${{ steps.load-cache.outputs.cache-hit || "false" }}
runs:
using: "composite"
steps:
- name: Validate Packages
run: ${{ github.action_path }}/validate_pkgs.sh ${{ inputs.packages }}
shell: bash
- name: Create Cache Key
run: echo ${{ inputs.packages }} "cache-apt-pkgs-version:${{ inputs.version }}" | sed 's/[\s,]+/\n/g' | sort > package_list.txt
shell: bash
- name: Load Package Cache
id: load-cache
uses: actions/cache@v2
with:
path: ~/cache-apt-pkgs
key: cache-apt-pkgs_${{ hashFiles('package_list.txt') }}
- name: Load Packages
run: |
if [ ${{ steps.load-cache.outputs.cache-hit }} ]; then
${{ github.action_path }}/restore_pkgs.sh ~/cache-apt-pkgs /
else
${{ github.action_path }}/install_and_cache_pkgs.sh ~/cache-apt-pkgs ${{ inputs.packages }}
fi
shell: bash