Add outputs to track running of this action
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?
Also see https://github.com/styfle/cancel-workflow-action/issues/23#issuecomment-658040746
Wouldn't it be better to use
outputsinstead?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.
Hello @JoseThen and @styfle, I hope you're doing well ! Do you have any update on this issue 😄 ?
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 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).
I should have time tomorrow, if it's fine with @styfle , I'll take another look at this.
Thanks !!
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 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 !😅
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 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 😄
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 Sounds good for me !
That would be great to have, simple and concise.
Hey! Has anyone had a chance to work on this? If not, I may be able to do so soon 😄
Closing since there are no upvotes on this issue and no one is working on it