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:
|
|
|
|
description: 'Version will create a new cache and install packages.'
|
|
|
|
required: false
|
|
|
|
default: ''
|
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-14 04:11:27 +00:00
|
|
|
|
|
|
|
runs:
|
|
|
|
using: "composite"
|
|
|
|
steps:
|
|
|
|
- name: Validate Packages
|
|
|
|
run: ${{ github.action_path }}/validate_pkgs.sh ${{ inputs.packages }}
|
2021-10-16 17:54:31 +00:00
|
|
|
shell: bash
|
2021-10-14 04:11:27 +00:00
|
|
|
|
|
|
|
- name: Create Cache Key
|
2021-10-16 19:48:07 +00:00
|
|
|
run: echo ${{ inputs.packages }} "cache-apt-pkgs-version:${{ inputs.version }}" | sed 's/[\s,]+/\n/g' | sort > package_list.txt
|
2021-10-14 04:11:27 +00:00
|
|
|
shell: bash
|
|
|
|
|
|
|
|
- name: Load Package Cache
|
2021-10-16 20:10:59 +00:00
|
|
|
id: load-cache
|
2021-10-14 04:11:27 +00:00
|
|
|
uses: actions/cache@v2
|
|
|
|
with:
|
|
|
|
path: ~/cache-apt-pkgs
|
2021-10-16 19:48:07 +00:00
|
|
|
key: cache-apt-pkgs_${{ hashFiles('package_list.txt') }}
|
2021-10-14 04:11:27 +00:00
|
|
|
|
2021-10-16 18:15:06 +00:00
|
|
|
- name: Load Packages
|
|
|
|
run: |
|
2021-10-16 20:10:59 +00:00
|
|
|
if [ ${{ steps.load-cache.outputs.cache-hit }} ]; then
|
2021-10-16 18:22:48 +00:00
|
|
|
${{ github.action_path }}/restore_pkgs.sh ~/cache-apt-pkgs /
|
2021-10-16 18:15:06 +00:00
|
|
|
else
|
2021-10-16 18:25:42 +00:00
|
|
|
${{ github.action_path }}/install_and_cache_pkgs.sh ~/cache-apt-pkgs ${{ inputs.packages }}
|
2021-10-16 18:19:36 +00:00
|
|
|
fi
|
2021-10-14 04:11:27 +00:00
|
|
|
shell: bash
|