@@ -9,7 +9,7 @@ let config: ActionConfig;
99let octokit : Octokit ;
1010
1111export function init ( cfg ?: ActionConfig ) : void {
12- config = cfg || getConfig ( ) ;
12+ config = cfg ?? getConfig ( ) ;
1313 octokit = github . getOctokit ( config . token ) ;
1414}
1515
@@ -27,6 +27,7 @@ export async function dispatchWorkflow(distinctId: string): Promise<void> {
2727 } ,
2828 } ) ;
2929
30+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
3031 if ( response . status !== 204 ) {
3132 throw new Error (
3233 `Failed to dispatch action, expected 204 but received ${ response . status } ` ,
@@ -48,7 +49,7 @@ export async function dispatchWorkflow(distinctId: string): Promise<void> {
4849 core . error (
4950 `dispatchWorkflow: An unexpected error has occurred: ${ error . message } ` ,
5051 ) ;
51- error . stack && core . debug ( error . stack ) ;
52+ core . debug ( error . stack ?? "" ) ;
5253 }
5354 throw error ;
5455 }
@@ -72,6 +73,7 @@ export async function getWorkflowId(workflowFilename: string): Promise<number> {
7273 let workflowId : number | undefined ;
7374
7475 for await ( const response of workflowIterator ) {
76+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
7577 if ( response . status !== 200 ) {
7678 throw new Error (
7779 `Failed to get workflows, expected 200 but received ${ response . status } ` ,
@@ -99,7 +101,7 @@ export async function getWorkflowId(workflowFilename: string): Promise<number> {
99101 core . error (
100102 `getWorkflowId: An unexpected error has occurred: ${ error . message } ` ,
101103 ) ;
102- error . stack && core . debug ( error . stack ) ;
104+ core . debug ( error . stack ?? "" ) ;
103105 }
104106 throw error ;
105107 }
@@ -114,6 +116,7 @@ export async function getWorkflowRunUrl(runId: number): Promise<string> {
114116 run_id : runId ,
115117 } ) ;
116118
119+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
117120 if ( response . status !== 200 ) {
118121 throw new Error (
119122 `Failed to get Workflow Run state, expected 200 but received ${ response . status } ` ,
@@ -133,7 +136,7 @@ export async function getWorkflowRunUrl(runId: number): Promise<string> {
133136 core . error (
134137 `getWorkflowRunUrl: An unexpected error has occurred: ${ error . message } ` ,
135138 ) ;
136- error . stack && core . debug ( error . stack ) ;
139+ core . debug ( error . stack ?? "" ) ;
137140 }
138141 throw error ;
139142 }
@@ -158,6 +161,7 @@ export async function getWorkflowRunIds(workflowId: number): Promise<number[]> {
158161 } ) ,
159162 } ) ;
160163
164+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
161165 if ( response . status !== 200 ) {
162166 throw new Error (
163167 `Failed to get Workflow runs, expected 200 but received ${ response . status } ` ,
@@ -171,9 +175,9 @@ export async function getWorkflowRunIds(workflowId: number): Promise<number[]> {
171175 core . debug (
172176 "Fetched Workflow Runs:\n" +
173177 ` Repository: ${ config . owner } /${ config . repo } \n` +
174- ` Branch: ${ branchName || "undefined" } \n` +
178+ ` Branch: ${ branchName } \n` +
175179 ` Workflow ID: ${ workflowId } \n` +
176- ` Runs Fetched: [${ runIds } ]` ,
180+ ` Runs Fetched: [${ runIds . join ( ", " ) } ]` ,
177181 ) ;
178182
179183 return runIds ;
@@ -182,7 +186,7 @@ export async function getWorkflowRunIds(workflowId: number): Promise<number[]> {
182186 core . error (
183187 `getWorkflowRunIds: An unexpected error has occurred: ${ error . message } ` ,
184188 ) ;
185- error . stack && core . debug ( error . stack ) ;
189+ core . debug ( error . stack ?? "" ) ;
186190 }
187191 throw error ;
188192 }
@@ -198,6 +202,7 @@ export async function getWorkflowRunJobSteps(runId: number): Promise<string[]> {
198202 filter : "latest" ,
199203 } ) ;
200204
205+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
201206 if ( response . status !== 200 ) {
202207 throw new Error (
203208 `Failed to get Workflow Run Jobs, expected 200 but received ${ response . status } ` ,
@@ -206,16 +211,16 @@ export async function getWorkflowRunJobSteps(runId: number): Promise<string[]> {
206211
207212 const jobs = response . data . jobs . map ( ( job ) => ( {
208213 id : job . id ,
209- steps : job . steps ?. map ( ( step ) => step . name ) || [ ] ,
214+ steps : job . steps ?. map ( ( step ) => step . name ) ?? [ ] ,
210215 } ) ) ;
211216 const steps = Array . from ( new Set ( jobs . flatMap ( ( job ) => job . steps ) ) ) ;
212217
213218 core . debug (
214219 "Fetched Workflow Run Job Steps:\n" +
215220 ` Repository: ${ config . owner } /${ config . repo } \n` +
216221 ` Workflow Run ID: ${ runId } \n` +
217- ` Jobs Fetched: [${ jobs . map ( ( job ) => job . id ) } ]` +
218- ` Steps Fetched: [${ steps } ]` ,
222+ ` Jobs Fetched: [${ jobs . map ( ( job ) => job . id ) . join ( ", " ) } ]` +
223+ ` Steps Fetched: [${ steps . join ( ", " ) } ]` ,
219224 ) ;
220225
221226 return steps ;
@@ -224,7 +229,7 @@ export async function getWorkflowRunJobSteps(runId: number): Promise<string[]> {
224229 core . error (
225230 `getWorkflowRunJobs: An unexpected error has occurred: ${ error . message } ` ,
226231 ) ;
227- error . stack && core . debug ( error . stack ) ;
232+ core . debug ( error . stack ?? "" ) ;
228233 }
229234 throw error ;
230235 }
0 commit comments