Cache APT packages in GitHub Actions
Go to file
Andrew Walsh 91b541353e
Fix issues #36, #37, and minor refactors. (#40) (#41)
* Bump license year.
* Fix pre-existing dep bug in issue #36.
* Account for packages without deps.
* Fix bug in issue #37 by combining install and dep listing reads. Ensures only installed deps are cached.
* Fix bad log lines.
* Use apt-fast to show package information and remove CLI warning message.
* Switch to apt-cache for package verification and remove CLI warning message.
2022-08-02 21:14:51 -07:00
.github/workflows Copy from staging to dev. 2022-07-19 20:42:48 -07:00
action.yml Minor bug. 2022-07-19 20:51:50 -07:00
install_and_cache_pkgs.sh Fix issues #36, #37, and minor refactors. (#40) (#41) 2022-08-02 21:14:51 -07:00
lib.sh Fix issues #36, #37, and minor refactors. (#40) (#41) 2022-08-02 21:14:51 -07:00
LICENSE Fix issues #36, #37, and minor refactors. (#40) (#41) 2022-08-02 21:14:51 -07:00
post_cache_action.sh Optimize installs with apt-fast and various minor cleanups. (#35) 2022-07-23 17:06:17 -07:00
pre_cache_action.sh Fix issues #36, #37, and minor refactors. (#40) (#41) 2022-08-02 21:14:51 -07:00
README.md Copy from staging to dev. 2022-07-19 20:42:48 -07:00
restore_pkgs.sh Optimize installs with apt-fast and various minor cleanups. (#35) 2022-07-23 17:06:17 -07:00

cache-apt-pkgs-action

License: Apache2 Master Test status Staging Test status

This action allows caching of Advanced Package Tool (APT) package dependencies to improve workflow execution time instead of installing the packages on every run.

Documentation

This action is a composition of actions/cache and the apt utility. Some actions require additional APT based packages to be installed in order for other steps to be executed. Packages can be installed when ran but can consume much of the execution workflow time.

Usage

Pre-requisites

Create a workflow .yml file in your repositories .github/workflows directory. An example workflow is available below. For more information, reference the GitHub Help Documentation for Creating a workflow file.

Inputs

  • 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.

Outputs

  • cache-hit - A boolean value to indicate a cache was found for the packages requested.
  • package-version-list - The main requested packages and versions that are installed. Represented as a comma delimited list with colon delimit on the package version (i.e. <package1>:<version1>,<package2>:<version2>,...).
  • all-package-version-list - All the pulled in packages and versions, including dependencies, that are installed. Represented as a comma delimited list with colon delimit on the package version (i.e. <package1>:<version1>,<package2>:<version2>,...).

Cache scopes

The cache is scoped to the packages given and the branch. The default branch cache is available to other branches.

Example workflow

This was a motivating use case for creating this action.

name: Create Documentation
on: push
jobs:
  
  build_and_deploy_docs:
    runs-on: ubuntu-latest
    name: Build Doxygen documentation and deploy
    steps:
      - uses: actions/checkout@v2
      - uses: awalsh128/cache-apt-pkgs-action@v1
        with:
          packages: dia doxygen doxygen-doc doxygen-gui doxygen-latex graphviz mscgen
          version: 1.0

      - name: Build        
        run: |
          cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}      
          cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}          

      - name: Deploy
        uses: JamesIves/github-pages-deploy-action@4.1.5
        with:
          branch: gh-pages
          folder: ${{github.workspace}}/build/website
...
  install_doxygen_deps:
    runs-on: ubuntu-latest    
    steps:
      - uses: actions/checkout@v2
      - uses: awalsh128/cache-apt-pkgs-action@v1
        with:
          packages: dia doxygen doxygen-doc doxygen-gui doxygen-latex graphviz mscgen
          version: 1.0
          refresh: true # Force refresh / upgrade v1.0 cache.

Cache Limits

A repository can have up to 5GB of caches. Once the 5GB limit is reached, older caches will be evicted based on when the cache was last accessed. Caches that are not accessed within the last week will also be evicted.