mirror of
https://github.com/awalsh128/cache-apt-pkgs-action.git
synced 2025-08-19 23:41:01 +00:00
Add empty_packages_behavior option to handle empty package list (#154)
Available options: 'error' (default), 'warn' and 'ignore'.
This commit is contained in:
parent
2c09a5e66d
commit
a605dbde2a
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue