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

Support canceling workflow runs #3775

Closed
jsoref opened this issue Jun 3, 2021 · 6 comments · Fixed by #3833
Closed

Support canceling workflow runs #3775

jsoref opened this issue Jun 3, 2021 · 6 comments · Fixed by #3833
Labels
actions enhancement a request to improve CLI help wanted Contributions welcome

Comments

@jsoref
Copy link
Contributor

jsoref commented Jun 3, 2021

Describe the feature or problem you’d like to solve

There is a REST api for canceling workflows, but https://cli.github.com/manual/gh_workflow doesn't support it.

Proposed solution

add gh run cancel $GITHUB_RUN_ID

How will it benefit CLI and its users?

Users won't have to write their own code to construct the URL and a curl request with credentials.

Additional context

I ended up implementing this myself, but I think a lot of what I'm doing would be nicer if I wasn't hand-rolling code.

@jsoref jsoref added the enhancement a request to improve CLI label Jun 3, 2021
@vilmibm vilmibm added actions help wanted Contributions welcome labels Jun 4, 2021
@vilmibm
Copy link
Contributor

vilmibm commented Jun 4, 2021

This would be a valuable addition, thanks for opening.

I'd like to see this implemented as gh run cancel and contributions are welcome; otherwise, we'll pick it up when we do the next phase of actions support.

@cristiand391
Copy link
Contributor

I'd like to work on this ✋🏾

@jsoref jsoref changed the title Support canceling workflows Support canceling workflow runs Jun 13, 2021
@jsoref
Copy link
Contributor Author

jsoref commented Jun 13, 2021

@cristiand391: please do.

You're going to want to add a directory for cancel here:
https://github.com/cli/cli/tree/09b09810dd812e3ede54b59ad9d6912b946ac6c5/pkg/cmd/run

You should be able to copy one of the existing directories and adjust the code to call the cancel method. You'd of course add the function to:
https://github.com/cli/cli/blob/09b09810dd812e3ede54b59ad9d6912b946ac6c5/pkg/cmd/run/run.go

@Jolg42
Copy link

Jolg42 commented Jul 8, 2021

Note: this would be really useful if it could cancel many runs at the same time.

Like gh run cancel all or gh run cancel name-of-workflow

@jsoref
Copy link
Contributor Author

jsoref commented Jul 8, 2021

Based on #3775 (comment), I suspect that would make more sense to do that as gh workflow cancel name-of-workflow.

I'm not opposed, but I don't want too much scope creep. If you don't mind, could you file a request for it separately? (Feel free to reference this so people can find it)

This initial request is based on a public endpoint that is currently not reflected in the CLI. It also has a PR that has been sitting in @vilmibm 's review queue for 20 days.

@Jolg42
Copy link

Jolg42 commented Jul 8, 2021

@jsoref created #3960 ✅ 👍🏼

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
actions enhancement a request to improve CLI help wanted Contributions welcome
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants