mirror of
https://github.com/awalsh128/cache-apt-pkgs-action.git
synced 2026-05-10 20:13:20 +00:00
Add add-repository parameter support for third-party PPAs
Co-authored-by: awalsh128 <2087466+awalsh128@users.noreply.github.com>
This commit is contained in:
parent
a90edda5bd
commit
8a6446804a
31
README.md
31
README.md
|
|
@ -36,6 +36,7 @@ There are three kinds of version labels you can use.
|
||||||
- `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'`.
|
- `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.
|
||||||
|
|
||||||
### Outputs
|
### Outputs
|
||||||
|
|
||||||
|
|
@ -90,6 +91,36 @@ install_doxygen_deps:
|
||||||
version: 1.0
|
version: 1.0
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Using with Third-party PPAs
|
||||||
|
|
||||||
|
This example shows how to install packages from a third-party PPA:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
install_from_ppa:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: awalsh128/cache-apt-pkgs-action@latest
|
||||||
|
with:
|
||||||
|
packages: chromium-browser
|
||||||
|
add-repository: ppa:canonical-chromium-builds/stage
|
||||||
|
version: 1.0
|
||||||
|
```
|
||||||
|
|
||||||
|
You can also add multiple repositories:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
install_from_multiple_repos:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: awalsh128/cache-apt-pkgs-action@latest
|
||||||
|
with:
|
||||||
|
packages: package1 package2
|
||||||
|
add-repository: ppa:user/repo1 ppa:user/repo2
|
||||||
|
version: 1.0
|
||||||
|
```
|
||||||
|
|
||||||
## Caveats
|
## Caveats
|
||||||
|
|
||||||
### Non-file Dependencies
|
### Non-file Dependencies
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,10 @@ inputs:
|
||||||
description: 'Enable debugging when there are issues with action. Minor performance penalty.'
|
description: 'Enable debugging when there are issues with action. Minor performance penalty.'
|
||||||
required: false
|
required: false
|
||||||
default: 'false'
|
default: 'false'
|
||||||
|
add-repository:
|
||||||
|
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: ''
|
||||||
|
|
||||||
outputs:
|
outputs:
|
||||||
cache-hit:
|
cache-hit:
|
||||||
|
|
@ -59,6 +63,7 @@ runs:
|
||||||
"$VERSION" \
|
"$VERSION" \
|
||||||
"$EXEC_INSTALL_SCRIPTS" \
|
"$EXEC_INSTALL_SCRIPTS" \
|
||||||
"$DEBUG" \
|
"$DEBUG" \
|
||||||
|
"$ADD_REPOSITORY" \
|
||||||
"$PACKAGES"
|
"$PACKAGES"
|
||||||
if [ -f ~/cache-apt-pkgs/cache_key.md5 ]; then
|
if [ -f ~/cache-apt-pkgs/cache_key.md5 ]; then
|
||||||
echo "CACHE_KEY=$(cat ~/cache-apt-pkgs/cache_key.md5)" >> $GITHUB_ENV
|
echo "CACHE_KEY=$(cat ~/cache-apt-pkgs/cache_key.md5)" >> $GITHUB_ENV
|
||||||
|
|
@ -71,6 +76,7 @@ runs:
|
||||||
EXEC_INSTALL_SCRIPTS: "${{ inputs.execute_install_scripts }}"
|
EXEC_INSTALL_SCRIPTS: "${{ inputs.execute_install_scripts }}"
|
||||||
EMPTY_PACKAGES_BEHAVIOR: "${{ inputs.empty_packages_behavior }}"
|
EMPTY_PACKAGES_BEHAVIOR: "${{ inputs.empty_packages_behavior }}"
|
||||||
DEBUG: "${{ inputs.debug }}"
|
DEBUG: "${{ inputs.debug }}"
|
||||||
|
ADD_REPOSITORY: "${{ inputs.add-repository }}"
|
||||||
PACKAGES: "${{ inputs.packages }}"
|
PACKAGES: "${{ inputs.packages }}"
|
||||||
|
|
||||||
- id: load-cache
|
- id: load-cache
|
||||||
|
|
@ -89,6 +95,7 @@ runs:
|
||||||
"$CACHE_HIT" \
|
"$CACHE_HIT" \
|
||||||
"$EXEC_INSTALL_SCRIPTS" \
|
"$EXEC_INSTALL_SCRIPTS" \
|
||||||
"$DEBUG" \
|
"$DEBUG" \
|
||||||
|
"$ADD_REPOSITORY" \
|
||||||
"$PACKAGES"
|
"$PACKAGES"
|
||||||
function create_list { local list=$(cat ~/cache-apt-pkgs/manifest_${1}.log | tr '\n' ','); echo ${list:0:-1}; };
|
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 "package-version-list=$(create_list main)" >> $GITHUB_OUTPUT
|
||||||
|
|
@ -98,6 +105,7 @@ runs:
|
||||||
CACHE_HIT: "${{ steps.load-cache.outputs.cache-hit }}"
|
CACHE_HIT: "${{ steps.load-cache.outputs.cache-hit }}"
|
||||||
EXEC_INSTALL_SCRIPTS: "${{ inputs.execute_install_scripts }}"
|
EXEC_INSTALL_SCRIPTS: "${{ inputs.execute_install_scripts }}"
|
||||||
DEBUG: "${{ inputs.debug }}"
|
DEBUG: "${{ inputs.debug }}"
|
||||||
|
ADD_REPOSITORY: "${{ inputs.add-repository }}"
|
||||||
PACKAGES: "${{ inputs.packages }}"
|
PACKAGES: "${{ inputs.packages }}"
|
||||||
|
|
||||||
- id: upload-logs
|
- id: upload-logs
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,11 @@ source "${script_dir}/lib.sh"
|
||||||
# Directory that holds the cached packages.
|
# Directory that holds the cached packages.
|
||||||
cache_dir="${1}"
|
cache_dir="${1}"
|
||||||
|
|
||||||
|
# Repositories to add before installing packages.
|
||||||
|
add_repository="${3}"
|
||||||
|
|
||||||
# List of the packages to use.
|
# List of the packages to use.
|
||||||
input_packages="${@:3}"
|
input_packages="${@:4}"
|
||||||
|
|
||||||
if ! apt-fast --version > /dev/null 2>&1; then
|
if ! apt-fast --version > /dev/null 2>&1; then
|
||||||
log "Installing apt-fast for optimized installs..."
|
log "Installing apt-fast for optimized installs..."
|
||||||
|
|
@ -27,6 +30,17 @@ if ! apt-fast --version > /dev/null 2>&1; then
|
||||||
log_empty_line
|
log_empty_line
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Add custom repositories if specified
|
||||||
|
if [ -n "${add_repository}" ]; then
|
||||||
|
log "Adding custom repositories..."
|
||||||
|
for repository in ${add_repository}; do
|
||||||
|
log "- Adding repository: ${repository}"
|
||||||
|
sudo apt-add-repository -y "${repository}"
|
||||||
|
done
|
||||||
|
log "done"
|
||||||
|
log_empty_line
|
||||||
|
fi
|
||||||
|
|
||||||
log "Updating APT package list..."
|
log "Updating APT package list..."
|
||||||
if [[ -z "$(find -H /var/lib/apt/lists -maxdepth 0 -mmin -5)" ]]; then
|
if [[ -z "$(find -H /var/lib/apt/lists -maxdepth 0 -mmin -5)" ]]; then
|
||||||
sudo apt-fast update > /dev/null
|
sudo apt-fast update > /dev/null
|
||||||
|
|
|
||||||
|
|
@ -25,13 +25,16 @@ execute_install_scripts="${4}"
|
||||||
debug="${5}"
|
debug="${5}"
|
||||||
test "${debug}" = "true" && set -x
|
test "${debug}" = "true" && set -x
|
||||||
|
|
||||||
|
# Repositories to add before installing packages.
|
||||||
|
add_repository="${6}"
|
||||||
|
|
||||||
# List of the packages to use.
|
# List of the packages to use.
|
||||||
packages="${@:6}"
|
packages="${@:7}"
|
||||||
|
|
||||||
if test "${cache_hit}" = "true"; then
|
if test "${cache_hit}" = "true"; then
|
||||||
${script_dir}/restore_pkgs.sh "${cache_dir}" "${cache_restore_root}" "${execute_install_scripts}" "${debug}"
|
${script_dir}/restore_pkgs.sh "${cache_dir}" "${cache_restore_root}" "${execute_install_scripts}" "${debug}"
|
||||||
else
|
else
|
||||||
${script_dir}/install_and_cache_pkgs.sh "${cache_dir}" "${debug}" ${packages}
|
${script_dir}/install_and_cache_pkgs.sh "${cache_dir}" "${debug}" "${add_repository}" ${packages}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
log_empty_line
|
log_empty_line
|
||||||
|
|
|
||||||
|
|
@ -24,8 +24,11 @@ execute_install_scripts="${3}"
|
||||||
# Debug mode for diagnosing issues.
|
# Debug mode for diagnosing issues.
|
||||||
debug="${4}"
|
debug="${4}"
|
||||||
|
|
||||||
|
# Repositories to add before installing packages.
|
||||||
|
add_repository="${5}"
|
||||||
|
|
||||||
# List of the packages to use.
|
# List of the packages to use.
|
||||||
input_packages="${@:5}"
|
input_packages="${@:6}"
|
||||||
|
|
||||||
# Trim commas, excess spaces, and sort.
|
# Trim commas, excess spaces, and sort.
|
||||||
log "Normalizing package list..."
|
log "Normalizing package list..."
|
||||||
|
|
@ -81,6 +84,12 @@ log "- CPU architecture is '${cpu_arch}'."
|
||||||
|
|
||||||
value="${packages} @ ${version} ${force_update_inc}"
|
value="${packages} @ ${version} ${force_update_inc}"
|
||||||
|
|
||||||
|
# Include repositories in cache key to ensure different repos get different caches
|
||||||
|
if [ -n "${add_repository}" ]; then
|
||||||
|
value="${value} ${add_repository}"
|
||||||
|
log "- Repositories '${add_repository}' added to value."
|
||||||
|
fi
|
||||||
|
|
||||||
# Don't invalidate existing caches for the standard Ubuntu runners
|
# Don't invalidate existing caches for the standard Ubuntu runners
|
||||||
if [ "${cpu_arch}" != "x86_64" ]; then
|
if [ "${cpu_arch}" != "x86_64" ]; then
|
||||||
value="${value} ${cpu_arch}"
|
value="${value} ${cpu_arch}"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue