| 141 | } |
| 142 | |
| 143 | func cancelWorkflowRun(client *api.Client, repo ghrepo.Interface, runID string, force bool) error { |
| 144 | var path *safeurl.MutableSafeURL |
| 145 | var err error |
| 146 | if force { |
| 147 | path, err = safeurl.JoinPath("repos", repo.RepoOwner(), repo.RepoName(), "actions", "runs", runID, "force-cancel") |
| 148 | } else { |
| 149 | path, err = safeurl.JoinPath("repos", repo.RepoOwner(), repo.RepoName(), "actions", "runs", runID, "cancel") |
| 150 | } |
| 151 | if err != nil { |
| 152 | return err |
| 153 | } |
| 154 | |
| 155 | err = client.REST(repo.RepoHost(), "POST", path.String(), nil, nil) |
| 156 | if err != nil { |
| 157 | return err |
| 158 | } |
| 159 | |
| 160 | return nil |
| 161 | } |