1
+ import * as core from '@actions/core'
2
+
1
3
// Helper function to add deployment statuses to a PR / ref
2
4
// :param octokit: The octokit client
3
5
// :param context: The GitHub Actions event context
@@ -86,18 +88,23 @@ export async function latestActiveDeployment(octokit, context, environment) {
86
88
environment : environment
87
89
}
88
90
91
+ let queryNumber = 1
89
92
let data = await octokit . graphql ( buildQuery ( ) , variables )
90
93
// nodes may be empty if no matching deployments were found - ex: []
91
94
let nodes = data . repository . deployments . nodes
92
95
93
96
// If no deployments were found, return null
94
97
if ( nodes . length === 0 ) {
98
+ core . debug ( `no deployments found for ${ environment } ` )
95
99
return null
96
100
}
97
101
98
102
// Check for an active deployment in the first page of deployments
99
103
let activeDeployment = nodes . find ( deployment => deployment . state === 'ACTIVE' )
100
104
if ( activeDeployment ) {
105
+ core . debug (
106
+ `found active deployment for ${ environment } in page ${ queryNumber } `
107
+ )
101
108
return activeDeployment
102
109
}
103
110
@@ -106,19 +113,31 @@ export async function latestActiveDeployment(octokit, context, environment) {
106
113
let endCursor = data . repository . deployments . pageInfo . endCursor
107
114
108
115
while ( hasNextPage ) {
116
+ queryNumber ++
109
117
data = await octokit . graphql ( buildQuery ( endCursor ) , variables )
110
118
111
119
nodes = data . repository . deployments . nodes
112
120
activeDeployment = nodes . find ( deployment => deployment . state === 'ACTIVE' )
113
121
114
122
if ( activeDeployment ) {
123
+ core . debug (
124
+ `found active deployment for ${ environment } in page ${ queryNumber } `
125
+ )
115
126
return activeDeployment
127
+ } else {
128
+ core . debug (
129
+ `no active deployment found for ${ environment } in page ${ queryNumber } `
130
+ )
116
131
}
117
132
118
133
hasNextPage = data . repository . deployments . pageInfo . hasNextPage
119
134
endCursor = data . repository . deployments . pageInfo . endCursor
120
135
}
121
136
137
+ core . debug (
138
+ `no active deployment found for ${ environment } after ${ queryNumber } pages`
139
+ )
140
+
122
141
// If no active deployment was found, return null
123
142
return null
124
143
}
0 commit comments