| 210 | } |
| 211 | |
| 212 | func rerunJob(client *api.Client, repo ghrepo.Interface, job *shared.Job, debug bool) error { |
| 213 | body, err := requestBody(debug) |
| 214 | if err != nil { |
| 215 | return fmt.Errorf("failed to create rerun body: %w", err) |
| 216 | } |
| 217 | |
| 218 | path := fmt.Sprintf("repos/%s/actions/jobs/%d/rerun", ghrepo.FullName(repo), job.ID) |
| 219 | |
| 220 | err = client.REST(repo.RepoHost(), "POST", path, body, nil) |
| 221 | if err != nil { |
| 222 | var httpError api.HTTPError |
| 223 | if errors.As(err, &httpError) && httpError.StatusCode == 403 { |
| 224 | return fmt.Errorf("job %d cannot be rerun", job.ID) |
| 225 | } |
| 226 | return fmt.Errorf("failed to rerun: %w", err) |
| 227 | } |
| 228 | return nil |
| 229 | } |
| 230 | |
| 231 | type RerunPayload struct { |
| 232 | Debug bool `json:"enable_debug_logging"` |