name: 'Cache APT Packages' description: 'Install APT based packages and cache them for future runs.' author: awalsh128 branding: icon: 'hard-drive' color: 'green' inputs: packages: description: 'Space delimited list of packages to install.' required: true default: '' version: description: 'Version will create a new cache and install packages.' required: false default: '' refresh: description: 'Option to refresh / upgrade the packages in the same cache.' required: false default: 'false' outputs: cache-hit: description: 'A boolean value to indicate a cache was found for the packages requested.' # 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 main requested packages and versions that are installed. Represented as a comma delimited list with colon delimit on the package version (i.e. ::).' value: ${{ steps.post-cache.outputs.package-version-list }} all-package-version-list: description: '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. ::).' value: ${{ steps.post-cache.outputs.all-package-version-list }} runs: using: "composite" steps: - id: pre-cache run: | ${{ github.action_path }}/pre_cache_action.sh \ ~/cache-apt-pkgs \ "${{ inputs.version }}" \ ${{ inputs.packages }} echo "CACHE_KEY=$(cat ~/cache-apt-pkgs/cache_key.md5)" >> $GITHUB_ENV shell: bash - id: load-cache uses: actions/cache@v3 with: path: ~/cache-apt-pkgs key: cache-apt-pkgs_${{ env.CACHE_KEY }} - id: post-cache run: | ${{ github.action_path }}/post_cache_action.sh \ ~/cache-apt-pkgs \ / \ "${{ steps.load-cache.outputs.cache-hit }}" \ ${{ inputs.packages }} 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 "all-package-version-list=$(create_list all)" >> $GITHUB_OUTPUT shell: bash