GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — v4.0 save always not working · Issue #1315 · actions/cache

v4.0 save always not working #1315

New issue
Copy link
New issue
Copy link
Closed
Closed
v4.0 save always not working#1315
Copy link
Assignees
joshmgross
Labels
bugSomething isn't working

Description

@DanMawdsleyBA
DanMawdsleyBA
opened on Jan 30, 2024
Issue body actions

I have setup the save always to true such that the cache step should always fail even if one of the tasks fail. See screenshots below:
Save always set to true in step:
image

Then further in the job a step fails but the post cache step is not run unlike the post repositry setup:
image

Related to
#1242

Reacted by Nils, gerhard-strauss-jambit, Anton Stoychev, Danny Gleckler, Aleksey Shapilov, Nikhil, Matthew Runyon, Sukka, Stacey Van Herk, Donald Huang and 26 more

Activity

  1. DanMawdsleyBA commented on Jan 30, 2024

    @DanMawdsleyBA
    DanMawdsleyBA
    on Jan 30, 2024
    Author
    More actions

    For context this is how I did save cache in v3:

    image

    I think we can also optimise like this to not attempt to save cache when there was a cache hit

    Reacted by Sukka and Simão Gomes Viana
  2. mattrunyon
    added a commit that references this issue on Feb 7, 2024

    ci: Fix JS caching (#270)

    3e24a20
  3. SukkaW commented on Feb 8, 2024

    @SukkaW
    SukkaW
    on Feb 8, 2024
    More actions

    I am also facing this issue. With save-always: true, the Post Cache is still skipped if the previous build step has failed:

    image
    Reacted by Wen Wei Tseng and n0099
  4. sascha-wolf commented on Feb 27, 2024

    @sascha-wolf
    sascha-wolf
    on Feb 27, 2024
    More actions

    We're observing the same issue. It just doesn't seem to work as documented.
    image

  5. amberin
    added a commit that references this issue on Mar 16, 2024

    The "save-always" flag in actions/cache is broken

    301ac4f
  6. epwilkins
    added a commit that references this issue on May 2, 2024

    #2 change from `save-always` flag to `if: always()` see actions/cache…

    b0392be
  7. aaron-gary
    added 2 commits that reference this issue on May 2, 2024

    # This is a combination of 31 commits.

    3f6ea16

    # This is a combination of 31 commits.

    bc94735
  8. joshmgross
    self-assigned this
    on Jun 12, 2024
  9. joshmgross
    added
    bugSomething isn't working
    on Jun 12, 2024
  10. joshmgross commented on Jun 12, 2024

    @joshmgross
    joshmgross
    on Jun 12, 2024
    Contributor
    More actions

    👋 Thank you for the bug report and apologies for the lack of a timely response.

    As I shared in #1325 (comment), I do not believe this is a feature we can support in this action today due to limitations in what's possible in post-if expressions.

    As @DanMawdsleyBA shared above, if you want to override the post-if behavior of the default cache action you can utilize the separate actions/cache/save and actions/cache/restore. This sort of granularity is what these actions were originally intended for - #1035.

    That might look something like:

    name: Always Caching Primes
    
    on: push
    
    jobs:
      build:
        runs-on: ubuntu-latest
    
        steps:
        - uses: actions/checkout@v4
    
        - name: Restore cached Primes
          id: cache-primes-restore
          uses: actions/cache/restore@v4
          with:
            path: |
              path/to/dependencies
              some/other/dependencies
            key: ${{ runner.os }}-primes
    
        # Intermediate workflow steps
    
        - name: Always Save Primes 
          id: cache-primes-save
          if: always() && steps.cache-primes-restore.outputs.cache-hit != 'true'
          uses: actions/cache/save@v4
          with:
            path: |
              path/to/dependencies
              some/other/dependencies
            key: ${{ steps.cache-primes-restore.outputs.cache-primary-key }}

    Given that save-always never worked, I believe it would make the most sense to deprecate that action input and remove it in a future version release. It's not something we can confidently support long term with the current features of post-if - any workarounds we implement today are likely to break in the future if they're relying on undocumented behavior. #1242 should not have been approved or merged without sufficient testing from us to validate that it was working as intended.

    My current plan is to:

    1. Deprecate save-always in the current major version to indicate to users that it's not working as intended
    2. Document in the README how to support this scenario with actions/cache/save
    3. Remove save-always in the next major version

    I realize this won't likely won't be a popular course of action, but I believe it's best for the long term maintainability of this action. I'd appreciate any and all feedback here, especially around the propose workaround if scenarios where it might not work.

    Reacted by Sukka, Andrei Radulescu, Clémence Lesné, Florian Koch, Danila Danko and William Entriken
    Reacted by Ruffin
  11. ruffsl commented on Jun 18, 2024

    @ruffsl
    ruffsl
    on Jun 18, 2024
    More actions

    Document in the README how to support this scenario with actions/cache/save

    @joshmgross , is there more that should be added to specified here?

    • https://github.com/actions/cache/blob/main/save/README.md#always-save-cache
  12. joshmgross commented on Jun 18, 2024

    @joshmgross
    joshmgross
    on Jun 18, 2024
    Contributor
    More actions

    Document in the README how to support this scenario with actions/cache/save

    @joshmgross , is there more that should be added to specified here?

    • https://github.com/actions/cache/blob/main/save/README.md#always-save-cache

    I was thinking it'd make sense to include the cache-hit output in that if conditional. The dedicated save cache action won't have access to the intra action state used by the restore step to indicate if the save is necessary.

    cache/src/saveImpl.ts

    Lines 46 to 48 in 0c45773

    // If matched restore key is same as primary key, then do not save cache
    // NO-OP in case of SaveOnly action
    const restoredKey = stateProvider.getCacheState();

  13. ruffsl
    added a commit that references this issue on Jul 6, 2024

    Use separate cache step to save via if always

    a6497ad
  14. XSAM
    added a commit that references this issue on Aug 9, 2024

    Save benchmark cache even the job is failed (#5694)

    b5a9cfb
  15. mraerino
    added a commit that references this issue on Aug 12, 2024

    Ensure cache is always saved

    4efe30b
  16. joshmgross
    added a commit that references this issue on Aug 14, 2024

    Deprecate `save-always` input

    5eda781
  17. svaningelgem
    added a commit that references this issue on Aug 22, 2024

    Bug actions/cache#1315 <-- save-always not working.

    8af0471
  18. fulldecent commented on Sep 9, 2024

    @fulldecent
    fulldecent
    on Sep 9, 2024
    More actions

    Here is the current documentation with the workaround.

    And it does NOT recommend using save-always

    https://github.com/actions/cache/blob/main/caching-strategies.md#saving-cache-even-if-the-build-fails

  19. midleman
    added a commit that references this issue on Sep 13, 2024

    smoke tests: leverage caching (#4665)

    4fbd3c7
  20. joshmgross
    added a commit that references this issue on Oct 3, 2024

    Deprecate `save-always` input (#1452)

    c74ca40
  21. joshmgross commented on Oct 7, 2024

    @joshmgross
    joshmgross
    on Oct 7, 2024
    Contributor
    More actions

    save-always has been deprecated as it's not something we can support at this time. #1452

    See #1315 (comment) for more details.

  22. joshmgross
    closed this as completedon Oct 7, 2024
  23. SukkaW
    added 2 commits that reference this issue on Oct 7, 2024

    CI: migrate cache save always

    4e746f7

    CI: migrate cache save always

    373b12f
  24. mmatl
    added a commit that references this issue on Jul 23, 2025

    fix: vulnerabilities (#2)

    ab60f7f
  25. ruffsl
    added a commit that references this issue on Jul 30, 2025

    Use separate cache step to save via if always

    cb0161f
  26. hub966
    added a commit that references this issue on Jul 24, 2026

    Merge pull request actions#1747 from actions/yacaovsnc/update-depende…

    5293c36
  27. SajmustafaKe
    added 2 commits that reference this issue on Sep 28, 2026

    Fix native addon cache ordering and force baseline x64 ISA

    38c5b6a

    Restore Windows x64 release packaging, fix oh-my-pi CI provisioning g…

    2e0a2cc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @joshmgross
    joshmgross

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.