forked from awalsh128/cache-apt-pkgs-action
-
Notifications
You must be signed in to change notification settings - Fork 1
/
action.yml
80 lines (74 loc) · 3.19 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
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