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