diff --git a/.changeset/little-doors-smell.md b/.changeset/little-doors-smell.md new file mode 100644 index 0000000000..970854d3f3 --- /dev/null +++ b/.changeset/little-doors-smell.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-github-actions': patch +--- + +Fixed GitHub workflows not appearing when the originating repository for a workflow run was deleted. diff --git a/plugins/github-actions/src/components/WorkflowRunsTable/WorkflowRunsTable.tsx b/plugins/github-actions/src/components/WorkflowRunsTable/WorkflowRunsTable.tsx index 82f7d64484..f04ec90323 100644 --- a/plugins/github-actions/src/components/WorkflowRunsTable/WorkflowRunsTable.tsx +++ b/plugins/github-actions/src/components/WorkflowRunsTable/WorkflowRunsTable.tsx @@ -50,7 +50,7 @@ export type WorkflowRun = { branchName: string; commit: { hash: string; - url: string; + url?: string; }; }; status: string; diff --git a/plugins/github-actions/src/components/useWorkflowRuns.ts b/plugins/github-actions/src/components/useWorkflowRuns.ts index eb453e6221..0690632a7b 100644 --- a/plugins/github-actions/src/components/useWorkflowRuns.ts +++ b/plugins/github-actions/src/components/useWorkflowRuns.ts @@ -43,53 +43,48 @@ export function useWorkflowRuns({ const { loading, value: runs, retry, error } = useAsyncRetry< WorkflowRun[] >(async () => { - return ( - api - // GitHub API pagination count starts from 1 - .listWorkflowRuns({ - hostname, - owner, - repo, - pageSize, - page: page + 1, - branch, - }) - .then((workflowRunsData): WorkflowRun[] => { - setTotal(workflowRunsData.total_count); - // Transformation here - return workflowRunsData.workflow_runs.map(run => ({ - workflowName: run.name, - message: run.head_commit.message, - id: `${run.id}`, - onReRunClick: async () => { - try { - await api.reRunWorkflow({ - hostname, - owner, - repo, - runId: run.id, - }); - } catch (e) { - errorApi.post(e); - } - }, - source: { - branchName: run.head_branch, - commit: { - hash: run.head_commit.id, - url: run.head_repository.branches_url.replace( - '{/branch}', - run.head_branch, - ), - }, - }, - status: run.status, - conclusion: run.conclusion, - url: run.url, - githubUrl: run.html_url, - })); - }) - ); + // GitHub API pagination count starts from 1 + const workflowRunsData = await api.listWorkflowRuns({ + hostname, + owner, + repo, + pageSize, + page: page + 1, + branch, + }); + setTotal(workflowRunsData.total_count); + // Transformation here + return workflowRunsData.workflow_runs.map(run => ({ + workflowName: run.name, + message: run.head_commit.message, + id: `${run.id}`, + onReRunClick: async () => { + try { + await api.reRunWorkflow({ + hostname, + owner, + repo, + runId: run.id, + }); + } catch (e) { + errorApi.post(e); + } + }, + source: { + branchName: run.head_branch, + commit: { + hash: run.head_commit.id, + url: run.head_repository?.branches_url?.replace( + '{/branch}', + run.head_branch, + ), + }, + }, + status: run.status, + conclusion: run.conclusion, + url: run.url, + githubUrl: run.html_url, + })); }, [page, pageSize, repo, owner]); return [