| 215 | } |
| 216 | |
| 217 | func rerunJob(client *api.Client, repo ghrepo.Interface, job *shared.Job, debug bool) error { |
| 218 | body, err := requestBody(debug) |
| 219 | if err != nil { |
| 220 | return fmt.Errorf("failed to create rerun body: %w", err) |
| 221 | } |
| 222 | |
| 223 | path, err := safeurl.JoinPath("repos", repo.RepoOwner(), repo.RepoName(), "actions", "jobs", strconv.FormatInt(job.ID, 10), "rerun") |
| 224 | if err != nil { |
| 225 | return err |
| 226 | } |
| 227 | |
| 228 | err = client.REST(repo.RepoHost(), "POST", path.String(), body, nil) |
| 229 | if err != nil { |
| 230 | var httpError api.HTTPError |
| 231 | if errors.As(err, &httpError) && httpError.StatusCode == 403 { |
| 232 | return fmt.Errorf("job %d cannot be rerun", job.ID) |
| 233 | } |
| 234 | return fmt.Errorf("failed to rerun: %w", err) |
| 235 | } |
| 236 | return nil |
| 237 | } |
| 238 | |
| 239 | type RerunPayload struct { |
| 240 | Debug bool `json:"enable_debug_logging"` |