mirror of
https://github.com/awalsh128/cache-apt-pkgs-action.git
synced 2026-01-04 17:43:33 +00:00
add setting to disable Aptfile usage
This commit is contained in:
parent
8a1823b41e
commit
32569df7e7
13
README.md
13
README.md
|
|
@ -37,6 +37,7 @@ There are three kinds of version labels you can use.
|
|||
- `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'`.
|
||||
- `add-repository` - Space delimited list of repositories to add via `apt-add-repository` before installing packages. Supports PPA (e.g., `ppa:user/repo`) and other repository formats.
|
||||
- `use_aptfile` - Whether to read packages from `Aptfile` at repository root. Set to `false` to disable Aptfile usage even if `Aptfile` exists. Default is `true`.
|
||||
|
||||
### Outputs
|
||||
|
||||
|
|
@ -164,6 +165,18 @@ You can also combine packages from both the input and `Aptfile`:
|
|||
packages: protobuf-compiler sd # Additional packages beyond Aptfile
|
||||
```
|
||||
|
||||
### Disabling Aptfile Usage
|
||||
|
||||
If you want to disable Aptfile reading even when an `Aptfile` exists in your repository, set `use_aptfile` to `false`:
|
||||
|
||||
```yaml
|
||||
- uses: awalsh128/cache-apt-pkgs-action@latest
|
||||
with:
|
||||
version: v1
|
||||
packages: cmake build-essential
|
||||
use_aptfile: false # Ignore Aptfile even if it exists
|
||||
```
|
||||
|
||||
## Caveats
|
||||
|
||||
### Non-file Dependencies
|
||||
|
|
|
|||
|
|
@ -39,6 +39,10 @@ inputs:
|
|||
description: 'Space delimited list of repositories to add via apt-add-repository before installing packages. Supports PPA (ppa:user/repo) and other repository formats.'
|
||||
required: false
|
||||
default: ''
|
||||
use_aptfile:
|
||||
description: 'Whether to read packages from Aptfile at repository root. Set to false to disable Aptfile usage even if Aptfile exists.'
|
||||
required: false
|
||||
default: 'true'
|
||||
|
||||
outputs:
|
||||
cache-hit:
|
||||
|
|
@ -64,6 +68,7 @@ runs:
|
|||
"$EXEC_INSTALL_SCRIPTS" \
|
||||
"$DEBUG" \
|
||||
"$ADD_REPOSITORY" \
|
||||
"$USE_APTFILE" \
|
||||
"$PACKAGES"
|
||||
if [ -f ~/cache-apt-pkgs/cache_key.md5 ]; then
|
||||
echo "CACHE_KEY=$(cat ~/cache-apt-pkgs/cache_key.md5)" >> $GITHUB_ENV
|
||||
|
|
@ -77,6 +82,7 @@ runs:
|
|||
EMPTY_PACKAGES_BEHAVIOR: "${{ inputs.empty_packages_behavior }}"
|
||||
DEBUG: "${{ inputs.debug }}"
|
||||
ADD_REPOSITORY: "${{ inputs.add-repository }}"
|
||||
USE_APTFILE: "${{ inputs.use_aptfile }}"
|
||||
PACKAGES: "${{ inputs.packages }}"
|
||||
|
||||
- id: load-cache
|
||||
|
|
|
|||
|
|
@ -27,24 +27,32 @@ debug="${4}"
|
|||
# Repositories to add before installing packages.
|
||||
add_repository="${5}"
|
||||
|
||||
# Whether to use Aptfile
|
||||
use_aptfile="${6}"
|
||||
validate_bool "${use_aptfile}" use_aptfile 5
|
||||
|
||||
# List of the packages to use.
|
||||
input_packages="${@:6}"
|
||||
input_packages="${@:7}"
|
||||
|
||||
# Check for Aptfile at repository root and merge with input packages
|
||||
aptfile_path="${GITHUB_WORKSPACE:-.}/Aptfile"
|
||||
aptfile_packages=""
|
||||
if test -n "${GITHUB_WORKSPACE}" && test -f "${aptfile_path}"; then
|
||||
log "Found Aptfile at ${aptfile_path}, parsing packages..."
|
||||
aptfile_packages="$(parse_aptfile "${aptfile_path}")"
|
||||
if test -n "${aptfile_packages}"; then
|
||||
log "Parsed $(echo "${aptfile_packages}" | wc -w) package(s) from Aptfile"
|
||||
if test "${use_aptfile}" = "true"; then
|
||||
if test -n "${GITHUB_WORKSPACE}" && test -f "${aptfile_path}"; then
|
||||
log "Found Aptfile at ${aptfile_path}, parsing packages..."
|
||||
aptfile_packages="$(parse_aptfile "${aptfile_path}")"
|
||||
if test -n "${aptfile_packages}"; then
|
||||
log "Parsed $(echo "${aptfile_packages}" | wc -w) package(s) from Aptfile"
|
||||
else
|
||||
log "Aptfile is empty or contains only comments"
|
||||
fi
|
||||
elif test -z "${GITHUB_WORKSPACE}"; then
|
||||
log "GITHUB_WORKSPACE not set, skipping Aptfile check"
|
||||
else
|
||||
log "Aptfile is empty or contains only comments"
|
||||
log "No Aptfile found at ${aptfile_path}"
|
||||
fi
|
||||
elif test -z "${GITHUB_WORKSPACE}"; then
|
||||
log "GITHUB_WORKSPACE not set, skipping Aptfile check"
|
||||
else
|
||||
log "No Aptfile found at ${aptfile_path}"
|
||||
log "Aptfile usage is disabled (use_aptfile=false)"
|
||||
fi
|
||||
|
||||
# Merge input packages with Aptfile packages
|
||||
|
|
|
|||
Loading…
Reference in a new issue