feat: add deployment statuses to GithubDeployments plugin

Signed-off-by: sam-robson <srobson@gocardless.com>
This commit is contained in:
sam-robson
2021-05-17 15:08:11 +01:00
parent 9d51b7e128
commit ef2f928f4a
3 changed files with 53 additions and 6 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-github-deployments': minor
---
Add deployment statuses to the GithubDeployments plugin
+20 -2
View File
@@ -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
}
}
+28 -4
View File
@@ -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: '',
},