From 4b4b09954d692693bd3b6d91731b378f4441bd6b Mon Sep 17 00:00:00 2001 From: Ryan Mast Date: Wed, 22 Apr 2020 00:07:37 -0700 Subject: [PATCH 1/2] Add DeleteWorkflowRunLogs function --- github/actions_workflow_runs.go | 14 ++++++++++++++ github/actions_workflow_runs_test.go | 15 +++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/github/actions_workflow_runs.go b/github/actions_workflow_runs.go index 8b12944184a..a67a83c17df 100644 --- a/github/actions_workflow_runs.go +++ b/github/actions_workflow_runs.go @@ -179,3 +179,17 @@ func (s *ActionsService) GetWorkflowRunLogs(ctx context.Context, owner, repo str parsedURL, err := url.Parse(resp.Header.Get("Location")) return parsedURL, newResponse(resp), err } + +// DeleteWorkflowRunLogs deletes all logs for a workflow run. +// +// GitHub API docs: https://developer.github.com/v3/actions/workflow_runs/#delete-workflow-run-logs +func (s *ActionsService) DeleteWorkflowRunLogs(ctx context.Context, owner, repo string, runID int64) (*Response, error) { + u := fmt.Sprintf("repos/%v/%v/actions/runs/%v/logs", owner, repo, runID) + + req, err := s.client.NewRequest("DELETE", u, nil) + if err != nil { + return nil, err + } + + return s.client.Do(ctx, req, nil) +} diff --git a/github/actions_workflow_runs_test.go b/github/actions_workflow_runs_test.go index 48e5cc30af3..d233819b7f8 100644 --- a/github/actions_workflow_runs_test.go +++ b/github/actions_workflow_runs_test.go @@ -235,3 +235,18 @@ func TestActionService_ListRepositoryWorkflowRuns(t *testing.T) { } } + +func TestActionService_DeleteWorkflowRunLogs(t *testing.T) { + client, mux, _, teardown := setup() + defer teardown() + + mux.HandleFunc("/repos/o/r/actions/runs/399444496/logs", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "DELETE") + + w.WriteHeader(http.StatusNoContent) + }) + + if _, err := client.Actions.DeleteWorkflowRunLogs(context.Background(), "o", "r", 399444496); err != nil { + t.Errorf("DeleteWorkflowRunLogs returned error: %v", err) + } +} From ba5fed3ba5f9adc647b69fc413d1a34053e64ee8 Mon Sep 17 00:00:00 2001 From: Ryan Mast Date: Sat, 25 Apr 2020 08:24:23 -0700 Subject: [PATCH 2/2] Update URL to API doc --- github/actions_workflow_runs.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github/actions_workflow_runs.go b/github/actions_workflow_runs.go index a67a83c17df..e3ca148afdf 100644 --- a/github/actions_workflow_runs.go +++ b/github/actions_workflow_runs.go @@ -182,7 +182,7 @@ func (s *ActionsService) GetWorkflowRunLogs(ctx context.Context, owner, repo str // DeleteWorkflowRunLogs deletes all logs for a workflow run. // -// GitHub API docs: https://developer.github.com/v3/actions/workflow_runs/#delete-workflow-run-logs +// GitHub API docs: https://developer.github.com/v3/actions/workflow-runs/#delete-workflow-run-logs func (s *ActionsService) DeleteWorkflowRunLogs(ctx context.Context, owner, repo string, runID int64) (*Response, error) { u := fmt.Sprintf("repos/%v/%v/actions/runs/%v/logs", owner, repo, runID)