Skip to content

Commit

Permalink
Merge pull request #5181 from backstage/timbonicus/workflow-runs-dele…
Browse files Browse the repository at this point in the history
…ted-fork

Make GitHub workflow run source.commit.url optional
  • Loading branch information
benjdlambert committed Mar 31, 2021
2 parents aa618e5 + 2c29611 commit 7aabf97
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 48 deletions.
5 changes: 5 additions & 0 deletions .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.
Expand Up @@ -50,7 +50,7 @@ export type WorkflowRun = {
branchName: string;
commit: {
hash: string;
url: string;
url?: string;
};
};
status: string;
Expand Down
89 changes: 42 additions & 47 deletions plugins/github-actions/src/components/useWorkflowRuns.ts
Expand Up @@ -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 [
Expand Down

0 comments on commit 7aabf97

Please sign in to comment.