mirror of
https://github.com/awalsh128/cache-apt-pkgs-action.git
synced 2025-09-05 07:23:14 +00:00
Compare commits
4 commits
Author | SHA1 | Date | |
---|---|---|---|
|
9f7a885e33 | ||
|
a605dbde2a | ||
|
2c09a5e66d | ||
|
9a146f43d1 |
|
@ -35,6 +35,7 @@ There are three kinds of version labels you can use.
|
||||||
- `packages` - Space delimited list of packages to install.
|
- `packages` - Space delimited list of packages to install.
|
||||||
- `version` - Version of cache to load. Each version will have its own cache. Note, all characters except spaces are allowed.
|
- `version` - Version of cache to load. Each version will have its own cache. Note, all characters except spaces are allowed.
|
||||||
- `execute_install_scripts` - Execute Debian package pre and post install script upon restore. See [Caveats / Non-file Dependencies](#non-file-dependencies) for more information.
|
- `execute_install_scripts` - Execute Debian package pre and post install script upon restore. See [Caveats / Non-file Dependencies](#non-file-dependencies) for more information.
|
||||||
|
- `empty_packages_behavior` - Desired behavior when the given `packages` is empty. `'error'` (default), `'warn'` or `'ignore'`.
|
||||||
|
|
||||||
### Outputs
|
### Outputs
|
||||||
|
|
||||||
|
|
23
action.yml
23
action.yml
|
@ -18,6 +18,16 @@ inputs:
|
||||||
description: 'Execute Debian package pre and post install script upon restore. See README.md caveats for more information.'
|
description: 'Execute Debian package pre and post install script upon restore. See README.md caveats for more information.'
|
||||||
required: false
|
required: false
|
||||||
default: 'false'
|
default: 'false'
|
||||||
|
empty_packages_behavior:
|
||||||
|
description: >
|
||||||
|
Desired behavior when the provided package list is empty.
|
||||||
|
|
||||||
|
Available Options:
|
||||||
|
error: Fail the action with an error message
|
||||||
|
warn: Output a warning without failing the action
|
||||||
|
ignore: Proceed silently without warnings or errors
|
||||||
|
required: false
|
||||||
|
default: 'error'
|
||||||
refresh:
|
refresh:
|
||||||
description: 'OBSOLETE: Refresh is not used by the action, use version instead.'
|
description: 'OBSOLETE: Refresh is not used by the action, use version instead.'
|
||||||
deprecationMessage: 'Refresh is not used by the action, use version instead.'
|
deprecationMessage: 'Refresh is not used by the action, use version instead.'
|
||||||
|
@ -50,21 +60,28 @@ runs:
|
||||||
"$EXEC_INSTALL_SCRIPTS" \
|
"$EXEC_INSTALL_SCRIPTS" \
|
||||||
"$DEBUG" \
|
"$DEBUG" \
|
||||||
"$PACKAGES"
|
"$PACKAGES"
|
||||||
echo "CACHE_KEY=$(cat ~/cache-apt-pkgs/cache_key.md5)" >> $GITHUB_ENV
|
if [ -f ~/cache-apt-pkgs/cache_key.md5 ]; then
|
||||||
|
echo "CACHE_KEY=$(cat ~/cache-apt-pkgs/cache_key.md5)" >> $GITHUB_ENV
|
||||||
|
else
|
||||||
|
echo "CACHE_KEY=" >> $GITHUB_ENV
|
||||||
|
fi
|
||||||
shell: bash
|
shell: bash
|
||||||
env:
|
env:
|
||||||
VERSION: "${{ inputs.version }}"
|
VERSION: "${{ inputs.version }}"
|
||||||
EXEC_INSTALL_SCRIPTS: "${{ inputs.execute_install_scripts }}"
|
EXEC_INSTALL_SCRIPTS: "${{ inputs.execute_install_scripts }}"
|
||||||
|
EMPTY_PACKAGES_BEHAVIOR: "${{ inputs.empty_packages_behavior }}"
|
||||||
DEBUG: "${{ inputs.debug }}"
|
DEBUG: "${{ inputs.debug }}"
|
||||||
PACKAGES: "${{ inputs.packages }}"
|
PACKAGES: "${{ inputs.packages }}"
|
||||||
|
|
||||||
- id: load-cache
|
- id: load-cache
|
||||||
|
if: ${{ env.CACHE_KEY }}
|
||||||
uses: actions/cache/restore@v4
|
uses: actions/cache/restore@v4
|
||||||
with:
|
with:
|
||||||
path: ~/cache-apt-pkgs
|
path: ~/cache-apt-pkgs
|
||||||
key: cache-apt-pkgs_${{ env.CACHE_KEY }}
|
key: cache-apt-pkgs_${{ env.CACHE_KEY }}
|
||||||
|
|
||||||
- id: post-cache
|
- id: post-cache
|
||||||
|
if: ${{ env.CACHE_KEY }}
|
||||||
run: |
|
run: |
|
||||||
${GITHUB_ACTION_PATH}/post_cache_action.sh \
|
${GITHUB_ACTION_PATH}/post_cache_action.sh \
|
||||||
~/cache-apt-pkgs \
|
~/cache-apt-pkgs \
|
||||||
|
@ -84,14 +101,14 @@ runs:
|
||||||
PACKAGES: "${{ inputs.packages }}"
|
PACKAGES: "${{ inputs.packages }}"
|
||||||
|
|
||||||
- id: upload-logs
|
- id: upload-logs
|
||||||
if: ${{ inputs.debug == 'true' }}
|
if: ${{ env.CACHE_KEY && inputs.debug == 'true' }}
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: cache-apt-pkgs-logs_${{ env.CACHE_KEY }}
|
name: cache-apt-pkgs-logs_${{ env.CACHE_KEY }}
|
||||||
path: ~/cache-apt-pkgs/*.log
|
path: ~/cache-apt-pkgs/*.log
|
||||||
|
|
||||||
- id: save-cache
|
- id: save-cache
|
||||||
if: ${{ ! steps.load-cache.outputs.cache-hit }}
|
if: ${{ env.CACHE_KEY && ! steps.load-cache.outputs.cache-hit }}
|
||||||
uses: actions/cache/save@v4
|
uses: actions/cache/save@v4
|
||||||
with:
|
with:
|
||||||
path: ~/cache-apt-pkgs
|
path: ~/cache-apt-pkgs
|
||||||
|
|
BIN
apt_query-arm64
BIN
apt_query-arm64
Binary file not shown.
BIN
apt_query-x86
BIN
apt_query-x86
Binary file not shown.
|
@ -87,11 +87,23 @@ for installed_package in ${installed_packages}; do
|
||||||
read package_name package_ver < <(get_package_name_ver "${installed_package}")
|
read package_name package_ver < <(get_package_name_ver "${installed_package}")
|
||||||
log " * Caching ${package_name} to ${cache_filepath}..."
|
log " * Caching ${package_name} to ${cache_filepath}..."
|
||||||
|
|
||||||
# Pipe all package files (no folders) and installation control data to Tar.
|
# Pipe all package files (no folders), including symlinks, their targets, and installation control data to Tar.
|
||||||
tar -cf "${cache_filepath}" -C / --verbatim-files-from --files-from <( { dpkg -L "${package_name}" &&
|
tar -cf "${cache_filepath}" -C / --verbatim-files-from --files-from <(
|
||||||
get_install_script_filepath "" "${package_name}" "preinst" &&
|
{ dpkg -L "${package_name}" &&
|
||||||
get_install_script_filepath "" "${package_name}" "postinst" ;} |
|
get_install_script_filepath "" "${package_name}" "preinst" &&
|
||||||
while IFS= read -r f; do test -f "${f}" -o -L "${f}" && get_tar_relpath "${f}"; done )
|
get_install_script_filepath "" "${package_name}" "postinst" ; } |
|
||||||
|
while IFS= read -r f; do
|
||||||
|
if test -f "${f}" -o -L "${f}"; then
|
||||||
|
get_tar_relpath "${f}"
|
||||||
|
if [ -L "${f}" ]; then
|
||||||
|
target="$(readlink -f "${f}")"
|
||||||
|
if [ -f "${target}" ]; then
|
||||||
|
get_tar_relpath "${target}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
)
|
||||||
|
|
||||||
log " done (compressed size $(du -h "${cache_filepath}" | cut -f1))."
|
log " done (compressed size $(du -h "${cache_filepath}" | cut -f1))."
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -44,9 +44,20 @@ fi
|
||||||
|
|
||||||
# Is length of string zero?
|
# Is length of string zero?
|
||||||
if test -z "${packages}"; then
|
if test -z "${packages}"; then
|
||||||
log "aborted"
|
case "$EMPTY_PACKAGES_BEHAVIOR" in
|
||||||
log "Packages argument cannot be empty." >&2
|
ignore)
|
||||||
exit 3
|
exit 0
|
||||||
|
;;
|
||||||
|
warn)
|
||||||
|
echo "::warning::Packages argument is empty."
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
log "aborted"
|
||||||
|
log "Packages argument is empty." >&2
|
||||||
|
exit 3
|
||||||
|
;;
|
||||||
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
validate_bool "${execute_install_scripts}" execute_install_scripts 4
|
validate_bool "${execute_install_scripts}" execute_install_scripts 4
|
||||||
|
|
|
@ -52,6 +52,10 @@ func getNonVirtualPackage(executor exec.Executor, name string) (pkg *AptPackage,
|
||||||
func getPackage(executor exec.Executor, paragraph string) (pkg *AptPackage, err error) {
|
func getPackage(executor exec.Executor, paragraph string) (pkg *AptPackage, err error) {
|
||||||
errMsgs := []string{}
|
errMsgs := []string{}
|
||||||
for _, splitLine := range GetSplitLines(paragraph, ":", 2) {
|
for _, splitLine := range GetSplitLines(paragraph, ":", 2) {
|
||||||
|
if len(splitLine.Words) < 2 {
|
||||||
|
logging.Debug("Skipping invalid line: %+v\n", splitLine.Line)
|
||||||
|
continue
|
||||||
|
}
|
||||||
switch splitLine.Words[0] {
|
switch splitLine.Words[0] {
|
||||||
case "Package":
|
case "Package":
|
||||||
// Initialize since this will provide the first struct value if present.
|
// Initialize since this will provide the first struct value if present.
|
||||||
|
|
Loading…
Reference in a new issue