Make source commit url optional
Signed-off-by: Tim Hansen <timbonicus@gmail.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-github-actions': patch
|
||||
---
|
||||
|
||||
Fixed GitHub workflows not appearing when the originating repository for a workflow run was deleted.
|
||||
@@ -50,7 +50,7 @@ export type WorkflowRun = {
|
||||
branchName: string;
|
||||
commit: {
|
||||
hash: string;
|
||||
url: string;
|
||||
url?: string;
|
||||
};
|
||||
};
|
||||
status: string;
|
||||
|
||||
@@ -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 [
|
||||
|
||||
Reference in New Issue
Block a user