Only update apt lists when running in nektos/act environment

Co-authored-by: awalsh128 <2087466+awalsh128@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2025-10-04 06:50:33 +00:00
parent d6013a02d0
commit 75561fd6ee

7
lib.sh
View file

@ -138,13 +138,17 @@ function get_tar_relpath {
############################################################################### ###############################################################################
# Updates APT package lists if they are stale (modified more than 5 minutes ago). # Updates APT package lists if they are stale (modified more than 5 minutes ago).
# This ensures compatibility with environments like nektos/act where package lists # This ensures compatibility with environments like nektos/act where package lists
# may be empty or stale. # may be empty or stale. Only runs when ACT environment variable is set (nektos/act)
# to avoid slowing down normal GitHub Actions runs.
# Arguments: # Arguments:
# None # None
# Returns: # Returns:
# None # None
############################################################################### ###############################################################################
function update_apt_lists_if_stale { function update_apt_lists_if_stale {
# Only check for stale package lists when running in nektos/act
# GitHub Actions runners have fresh package lists, so skip this overhead
if [ "${ACT}" = "true" ]; then
if [[ -z "$(find -H /var/lib/apt/lists -maxdepth 0 -mmin -5 2>/dev/null)" ]]; then if [[ -z "$(find -H /var/lib/apt/lists -maxdepth 0 -mmin -5 2>/dev/null)" ]]; then
log "APT package lists are stale, updating..." log "APT package lists are stale, updating..."
if command -v apt-fast > /dev/null 2>&1; then if command -v apt-fast > /dev/null 2>&1; then
@ -156,6 +160,7 @@ function update_apt_lists_if_stale {
else else
log "APT package lists are fresh (within 5 minutes), skipping update" log "APT package lists are fresh (within 5 minutes), skipping update"
fi fi
fi
} }
function log { echo "${@}"; } function log { echo "${@}"; }