name: Install apt packages description: > Installs apt packages with bounded download retries and Ubuntu mirror fallback. Caches downloaded packages as an optimization; apt resolves dependencies on every run. inputs: packages: description: Space separated list of package names to install required: true attempts: description: Maximum number of download attempts default: "3" attempt-timeout: description: Seconds before a single download attempt is killed default: "180" runs: using: composite steps: - name: Identify apt cache id: cache-key shell: bash env: PACKAGES: ${{ inputs.packages }} run: | . /etc/os-release packages_hash=$(printf '%s' "$PACKAGES" | sha256sum | cut -d ' ' -f 1) # Cached downloads are optional: apt fetches any missing/newer packages. # Refresh weekly, including inside job containers without ImageVersion. echo "key=apt-v2-${ID}-${VERSION_ID}-$(dpkg --print-architecture)-$(date -u +%G-%V)-${packages_hash}" >> "$GITHUB_OUTPUT" - name: Restore apt packages id: cache uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 with: path: | ${{ runner.temp }}/apt-packages/*.deb ${{ runner.temp }}/apt-packages/.keep key: ${{ steps.cache-key.outputs.key }} - name: Install ${{ inputs.packages }} shell: bash env: PACKAGES: ${{ inputs.packages }} ATTEMPTS: ${{ inputs.attempts }} ATTEMPT_TIMEOUT: ${{ inputs.attempt-timeout }} CACHE_DIR: ${{ runner.temp }}/apt-packages run: bash "$GITHUB_ACTION_PATH/install.sh" # Save immediately: a later test failure must not discard downloaded packages. - name: Save apt packages if: steps.cache.outputs.cache-hit != 'true' uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 with: path: | ${{ runner.temp }}/apt-packages/*.deb ${{ runner.temp }}/apt-packages/.keep key: ${{ steps.cache-key.outputs.key }}