name: Cache on main description: Stores caches on main and release branches only, but restores them on all branches. inputs: path: description: Path(s) to cache required: true save-prs: description: Whether to additionally store the cache in a pull request, too. Should only be used for very small caches. type: boolean prefix: description: Cache key prefix to be used in both primary key and restore-keys. required: true suffix: description: Cache key suffix to be used only in primary key. required: true runs: using: composite steps: - uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 if: ${{ startsWith(github.ref, 'refs/heads/') || (inputs.save-prs && startsWith(github.ref, 'refs/pull/')) }} with: path: ${{ inputs.path }} key: ${{ runner.os }}-${{ inputs.prefix }}-${{ inputs.suffix }} restore-keys: | ${{ runner.os }}-${{ inputs.prefix }}- - uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 if: ${{ !startsWith(github.ref, 'refs/heads/') && !(inputs.save-prs && startsWith(github.ref, 'refs/pull/')) }} with: path: ${{ inputs.path }} key: ${{ runner.os }}-${{ inputs.prefix }}-${{ inputs.suffix }} restore-keys: | ${{ runner.os }}-${{ inputs.prefix }}-