cache-apt-pkgs-action/action.yml

45 lines
1.3 KiB
YAML
Raw Normal View History

2021-10-13 21:11:27 -07:00
name: 'Cache APT Packages'
description: 'Install APT based packages and cache them for future runs.'
author: awalsh128
2021-10-13 22:16:32 -07:00
branding:
icon: 'hard-drive'
color: 'green'
2021-10-13 21:11:27 -07:00
inputs:
packages:
description: 'Space delimited list of packages to install.'
required: true
default: ''
outputs:
cache-hit:
description: 'A boolean value to indicate a cache was found for the packages requested.'
value: ${{ steps.load-pkg-cache.outputs.cache-hit }}
runs:
using: "composite"
steps:
- name: Validate Packages
run: ${{ github.action_path }}/validate_pkgs.sh ${{ inputs.packages }}
2021-10-16 10:54:31 -07:00
shell: bash
2021-10-13 21:11:27 -07:00
- name: Create Cache Key
run: echo ${{ inputs.packages }} | sed 's/[\s,]+/\n/g' | sort > /tmp/package_list.txt
shell: bash
- name: Load Package Cache
id: load-pkg-cache
uses: actions/cache@v2
with:
path: ~/cache-apt-pkgs
key: cache-apt-pkgs_${{ hashFiles('/tmp/package_list.txt') }}
2021-10-16 11:15:06 -07:00
- name: Load Packages
run: |
if [ ${{ steps.load-pkg-cache.outputs.cache-hit }} ]; then
2021-10-16 11:22:48 -07:00
${{ github.action_path }}/restore_pkgs.sh ~/cache-apt-pkgs /
2021-10-16 11:15:06 -07:00
else
2021-10-16 11:25:42 -07:00
${{ github.action_path }}/install_and_cache_pkgs.sh ~/cache-apt-pkgs ${{ inputs.packages }}
fi
2021-10-13 21:11:27 -07:00
shell: bash