diff --git a/.changeset/shiny-hotels-tell.md b/.changeset/shiny-hotels-tell.md new file mode 100644 index 0000000000..d907f5e2b2 --- /dev/null +++ b/.changeset/shiny-hotels-tell.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-github-deployments': minor +--- + +Add deployment statuses to the GithubDeployments plugin diff --git a/plugins/github-deployments/src/api/index.ts b/plugins/github-deployments/src/api/index.ts index d7e7e2fca6..4049e082da 100644 --- a/plugins/github-deployments/src/api/index.ts +++ b/plugins/github-deployments/src/api/index.ts @@ -53,6 +53,10 @@ const getBaseUrl = ( return config?.config.apiBaseUrl; }; +type Node = { + logUrl?: string; +}; + export type GithubDeployment = { environment: string; state: string; @@ -61,9 +65,15 @@ export type GithubDeployment = { abbreviatedOid: string; commitUrl: string; }; + statuses: { + nodes: Node[]; + }; creator: { login: string; }; + repository: { + nameWithOwner: string; + }; payload: string; }; @@ -89,9 +99,9 @@ export type Options = { }; const deploymentsQuery = ` -query deployments($owner: String!, $repo: String!, $last: Int) { +query deployments($owner: String!, $repo: String!, $lastDeployments: Int, $lastStatuses: Int) { repository(owner: $owner, name: $repo) { - deployments(last: $last) { + deployments(last: $lastDeployments) { nodes { state environment @@ -100,9 +110,17 @@ query deployments($owner: String!, $repo: String!, $last: Int) { abbreviatedOid commitUrl } + statuses(last: $lastStatuses) { + nodes { + logUrl + } + } creator { login } + repository { + nameWithOwner + } payload } } diff --git a/plugins/github-deployments/src/mocks/mocks.ts b/plugins/github-deployments/src/mocks/mocks.ts index b2a75ac7b0..132d3e9d19 100644 --- a/plugins/github-deployments/src/mocks/mocks.ts +++ b/plugins/github-deployments/src/mocks/mocks.ts @@ -51,7 +51,13 @@ export const responseStub: QueryResponse = { creator: { login: 'robot-user-001', }, - payload: '{"target":"moon"}', + statuses: { + nodes: [{ logUrl: 'taskrun/example-run' }], + }, + repository: { + nameWithOwner: 'org/owner', + }, + payload: '', }, { state: 'pending', @@ -62,9 +68,15 @@ export const responseStub: QueryResponse = { abbreviatedOid: '54321', }, creator: { - login: 'robot-user-002', + login: 'robot-user-001', }, - payload: '{"target":"sun"}', + statuses: { + nodes: [{ logUrl: '' }], + }, + repository: { + nameWithOwner: 'org/owner', + }, + payload: '', }, ], }, @@ -86,6 +98,12 @@ export const refreshedResponseStub: QueryResponse = { creator: { login: 'robot-user-001', }, + statuses: { + nodes: [{ logUrl: 'taskrun/example-run' }], + }, + repository: { + nameWithOwner: 'org/owner', + }, payload: '', }, { @@ -97,7 +115,13 @@ export const refreshedResponseStub: QueryResponse = { abbreviatedOid: '54321', }, creator: { - login: 'robot-user-002', + login: 'robot-user-001', + }, + statuses: { + nodes: [{ logUrl: 'taskrun/example-run' }], + }, + repository: { + nameWithOwner: 'org/owner', }, payload: '', },