Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to actions/cache to not save conditionally #1493

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

EnricoMi
Copy link

@EnricoMi EnricoMi commented Nov 4, 2024

Description

Add an option to control the save post job.

Motivation and Context

With such an option, the save post job can be triggered conditionally like

- name: Cache
  uses: actions/cache@v4
  with:
    path: .cache
    key: ${{ runner.os }}-cache
    save: ${{  github.ref == 'refs/heads/master' }}

With that, there is no need to split the actions/cache step into a restore and save step which makes the workflow cluttered.

How Has This Been Tested?

Visual inspection of the test-dont-save jobs.

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation (add or update README or docs)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@EnricoMi EnricoMi requested a review from a team as a code owner November 4, 2024 19:08
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test-dont-save jobs shows that this is not sufficient to skip the post job if save: false. Pointers to the right place to add the if (doSave) appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant