diff --git a/README.md b/README.md index e03856e..37a25b9 100644 --- a/README.md +++ b/README.md @@ -19,10 +19,13 @@ Create a workflow `.yml` file in your repositories `.github/workflows` directory * `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. +* `refresh` - Refresh / upgrade the packages in the same cache. ### Outputs * `cache-hit` - A boolean value to indicate a cache was found for the packages requested. +* `package_version_list` - The packages and versions that are installed as a comma delimited list with colon delimit on the package version (i.e. \:,\:\,...). + ### Cache scopes @@ -59,6 +62,19 @@ jobs: folder: ${{github.workspace}}/build/website ``` +```yaml +... + 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. diff --git a/action.yml b/action.yml index 67ebb1c..bf92510 100644 --- a/action.yml +++ b/action.yml @@ -13,7 +13,11 @@ inputs: version: description: 'Version will create a new cache and install packages.' required: false - default: '' + default: '' + refresh: + description: 'Option to refresh / upgrade the packages in the same cache.' + required: false + default: 'false' outputs: cache-hit: @@ -21,6 +25,9 @@ outputs: # This compound expression is needed because lhs can be empty. # Need to output true and false instead of true and nothing. value: ${{ steps.load-cache.outputs.cache-hit || false }} + package_version_list: + description: 'The packages and versions that are installed as a comma delimited list with colon delimit on the package version (i.e. ::).' + value: ${{ steps.get-package-versions.outputs.package_version_list }} runs: using: "composite" @@ -42,10 +49,20 @@ runs: key: cache-apt-pkgs_${{ env.CACHE_KEY }} - name: Load Packages - run: | - if [ ${{ steps.load-cache.outputs.cache-hit }} ]; then - ${{ github.action_path }}/restore_pkgs.sh ~/cache-apt-pkgs / - else + run: | + if [ ! ${{ steps.load-cache.outputs.cache-hit }} ] || [ ${{ inputs.refresh }} ]; then ${{ github.action_path }}/install_and_cache_pkgs.sh ~/cache-apt-pkgs ${{ inputs.packages }} + else + ${{ github.action_path }}/restore_pkgs.sh ~/cache-apt-pkgs / fi shell: bash + + - name: Get Package Versions + id: get-package-versions + run: | + output= + for package in ${{ inputs.packages }}; do + output=$output,$package:$(dpkg -s xdot | grep Version | awk '{print $2}') + done + ::set-output name=package_version_list::output + shell: bash