| 186 | } |
| 187 | |
| 188 | func rerunRun(client *api.Client, repo ghrepo.Interface, run *shared.Run, onlyFailed, debug bool) error { |
| 189 | runVerb := "rerun" |
| 190 | if onlyFailed { |
| 191 | runVerb = "rerun-failed-jobs" |
| 192 | } |
| 193 | |
| 194 | body, err := requestBody(debug) |
| 195 | if err != nil { |
| 196 | return fmt.Errorf("failed to create rerun body: %w", err) |
| 197 | } |
| 198 | |
| 199 | path := fmt.Sprintf("repos/%s/actions/runs/%d/%s", ghrepo.FullName(repo), run.ID, runVerb) |
| 200 | |
| 201 | err = client.REST(repo.RepoHost(), "POST", path, body, nil) |
| 202 | if err != nil { |
| 203 | var httpError api.HTTPError |
| 204 | if errors.As(err, &httpError) && httpError.StatusCode == 403 { |
| 205 | return fmt.Errorf("run %d cannot be rerun; %s", run.ID, httpError.Message) |
| 206 | } |
| 207 | return fmt.Errorf("failed to rerun: %w", err) |
| 208 | } |
| 209 | return nil |
| 210 | } |
| 211 | |
| 212 | func rerunJob(client *api.Client, repo ghrepo.Interface, job *shared.Job, debug bool) error { |
| 213 | body, err := requestBody(debug) |