cancel-workflow-action icon indicating copy to clipboard operation
cancel-workflow-action copied to clipboard

Add outputs to track running of this action

Open JoseThen opened this issue 5 years ago • 16 comments

I was just thinking about, but it would be awesome if when this action runs (successfully canceling a previous run) it would set an environment variable that can be picked up by other steps to trigger cleanup steps?

JoseThen avatar Jul 15 '20 20:07 JoseThen

Wouldn't it be better to use outputs instead?

Also, what would the value be?

styfle avatar Jul 15 '20 21:07 styfle

Also see https://github.com/styfle/cancel-workflow-action/issues/23#issuecomment-658040746

styfle avatar Jul 15 '20 21:07 styfle

Wouldn't it be better to use outputs instead?

Also, what would the value be?

Using outputs sounds like the way to go. Going to have to test some more but wonder how I would get runningWorkflows.length as a value. That way I can add that as the output and run some commands based on the value.

JoseThen avatar Jul 16 '20 14:07 JoseThen

Hello @JoseThen and @styfle, I hope you're doing well ! Do you have any update on this issue 😄 ?

obrassard avatar Oct 09 '20 15:10 obrassard

Actually no updates from me, I should close this issue, are you needing this specific function for your use case? If so you mind saying what it is?

JoseThen avatar Oct 09 '20 15:10 JoseThen

@JoseThen Indeed, we would need this feature in obrassard/action-dokku-push (see : https://github.com/obrassard/action-dokku-push/issues/5). To resume, we use cancel-workflow-action to cancel concurrent builds and we would need an output to know if a previous build was cancelled or not (because additional steps must be executed in this case).

obrassard avatar Oct 09 '20 16:10 obrassard

I should have time tomorrow, if it's fine with @styfle , I'll take another look at this.

JoseThen avatar Oct 09 '20 17:10 JoseThen

Thanks !!

obrassard avatar Oct 09 '20 17:10 obrassard

So I did some light testing with https://github.com/styfle/cancel-workflow-action/compare/main...JoseThen:main . I guess the real question is how far you want to go with this "feature".

Example: https://github.com/JoseThen/cancel-workflow-action/runs/1236893939?check_suite_focus=true check Results step

JoseThen avatar Oct 11 '20 01:10 JoseThen

@JoseThen Thanks for your feedback. To answer your question, we don't need much details only a way to know if a previous build was cancelled by the action or not. So a success / failure flag is enough for our use case. However, I might be wrong, but it seems that in your branch you set core.setOutput('RESULT', 'failure'); only when there is an error (in the catch block), but we would also need to get the failure (or something else) flag in the case where there is no error, but no previous action was running / cancelled. Don't hesitate, to @ me if something is not clear !😅

obrassard avatar Oct 11 '20 05:10 obrassard

I read the original description of the issue and I don’t think we can determine “successfully canceling a previous run” easily.

The problem is that the GitHub API response is 202 Accepted meaning that the action finishes before GitHub actually cancels the workflow. See #23 for more info.

styfle avatar Oct 11 '20 21:10 styfle

@styfle Thanks, I understand that we cannot know if the cancelling was successful or not. Nonetheless, do we have a way to check if a previous build was running before cancelling it (vs if there was none) ? This is the information I would need 😄

obrassard avatar Oct 11 '20 21:10 obrassard

Yes that is possible. Basically we could return the status codes from the api as outputs so you get an empty array when nothing was cancelled or an array of 202 if all the ids were cancelled (or perhaps 500 if GH API was down).

We already log this information so it can be turned into Action outputs too.

styfle avatar Oct 11 '20 22:10 styfle

@styfle Sounds good for me !

obrassard avatar Oct 11 '20 22:10 obrassard

That would be great to have, simple and concise.

JoseThen avatar Oct 11 '20 22:10 JoseThen

Hey! Has anyone had a chance to work on this? If not, I may be able to do so soon 😄

obrassard avatar Oct 26 '20 23:10 obrassard

Closing since there are no upvotes on this issue and no one is working on it

styfle avatar Oct 03 '23 15:10 styfle