isac322 / buildkit-state

Github action for caching buildkit state
MIT License
5 stars 1 forks source link

Is there a way to make the post step run even if there's a failure? #17

Closed datalogics-kam closed 11 months ago

datalogics-kam commented 1 year ago

Thanks for the action! It's simple, clean, and easy to use.

My workflow looks like this (leaving out some details):

The problem is that since this action has post-if: success() step, the buildkit caches aren't saved if the tests fail.

Would it be possible to add an override to have the post-action part run despite failure?

I suppose I could fork the repo, and make a contribution for you to consider.

isac322 commented 1 year ago

@datalogics-kam Added new option save-on-failure on v2, please check out https://github.com/isac322/buildkit-state/tree/v2.0.0#inputs.

datalogics-kam commented 1 year ago

Thanks for the fix! I'm giving it a try, but it doesn't seem to save on failure for me...am I missing something?

Here's the step I'm using:

            - name: Cache and restore Docker buildkit state
              uses: isac322/buildkit-state@v2
              with:
                  buildx-name: ${{ steps.buildx.outputs.name }}
                  # Save the cache even if the tests fail
                  save-on-failure: true

And here are the debug logs where it decides to not do the post action:

##[debug]Evaluating condition for step: 'Post Cache and restore Docker buildkit state'
##[debug]Evaluating: (success() || github.event.inputs.save-on-failure)
##[debug]Evaluating Or:
##[debug]..Evaluating success:
##[debug]..=> false
##[debug]..Evaluating Index:
##[debug]....Evaluating Index:
##[debug]......Evaluating Index:
##[debug]........Evaluating github:
##[debug]........=> Object
##[debug]........Evaluating String:
##[debug]........=> 'event'
##[debug]......=> Object
##[debug]......Evaluating String:
##[debug]......=> 'inputs'
##[debug]....=> null
##[debug]..=> null
##[debug]=> null
##[debug]Expanded: (false || null)
##[debug]Result: null