Skip to content

optional action failure on cache miss #955

@deitch

Description

@deitch

Can we have an option to fail on cache miss? The current behaviour is:

  • cache hit: restore, exit successfully
  • cache miss: do not restore, exit successfully

Much of the time, the above makes sense. But there can be workflows where you might want to fail if cache miss. For example, 2 jobs that depend on each other and use cache to move ephemeral artifacts around. We don't want them as formal artifacts, but a cache miss should cause the job to stop.

Right now, you can do it with a little convolution:

      - name: update from cache
        id: cache
        uses: actions/cache@v3
        with:
          path: foo
          key: some-key
      - name: Fail if cache miss
        uses: actions/github-script@v6
        if: steps.cache.outputs.cache-hit != 'true'
        with:
          script: core.setFailed('Cache hit failed')

That gets unwieldy, especially if it has to be done in a few jobs. The following would be much easier:

      - name: update from cache
        id: cache
        uses: actions/cache@v3
        with:
          path: foo
          key: some-key
          fail_on_miss: true      # this, or some similar key

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions