@@ -132,9 +132,9 @@ async function main(): Promise<void> {
132132 ) ;
133133 skippedCount ++ ;
134134 }
135- } catch ( error ) {
135+ } catch ( error : any ) {
136136 console . error (
137- `❌ Failed to process issue #${ issue . number } : ${ error . message } ` ,
137+ `❌ Failed to process issue #${ issue . number } : ${ error ? .message || error } ` ,
138138 ) ;
139139 failedCount ++ ;
140140 failedIssues . push ( issue . number ) ;
@@ -167,9 +167,9 @@ async function main(): Promise<void> {
167167 } else {
168168 console . log ( `\n✅ All operations completed successfully!` ) ;
169169 }
170- } catch ( error ) {
170+ } catch ( error : any ) {
171171 core . setFailed (
172- `Error in Google Sheets RCA label removal: ${ error . message } ` ,
172+ `Error in Google Sheets RCA label removal: ${ error ? .message || error } ` ,
173173 ) ;
174174 process . exit ( 1 ) ;
175175 }
@@ -206,10 +206,39 @@ async function fetchRcaResponses(sheets: any): Promise<RcaFormResponse[]> {
206206 return [ ] ;
207207 }
208208
209- // Process data rows (skip header row at index 0)
210- // Column indices based on actual sheet:
211- // 0: Timestamp, 1: Email, 2: Github Repository, 3: Github Issue URL, 4: Issue Number
212- const ISSUE_NUMBER_COLUMN = 4 ;
209+ // Dynamically determine the column index for "Issue Number" from the header row
210+ const headerRow = rows [ 0 ] || [ ] ;
211+ const ISSUE_NUMBER_HEADER = 'Issue Number' ;
212+ const issueNumberColumnIndex = headerRow . findIndex (
213+ ( col : string ) => col && col . trim ( ) === ISSUE_NUMBER_HEADER ,
214+ ) ;
215+
216+ if ( issueNumberColumnIndex === - 1 ) {
217+ console . warn (
218+ `Could not find "${ ISSUE_NUMBER_HEADER } " column in sheet headers. Falling back to column E (index 4)` ,
219+ ) ;
220+ // Fallback to known column position for backwards compatibility
221+ const ISSUE_NUMBER_COLUMN = 4 ;
222+ const responses : RcaFormResponse [ ] = [ ] ;
223+ for ( let i = 1 ; i < rows . length ; i ++ ) {
224+ const row = rows [ i ] ;
225+ if ( ! row || row . length === 0 ) continue ;
226+ const issueNumberValue = row [ ISSUE_NUMBER_COLUMN ] ;
227+ if ( issueNumberValue ) {
228+ const issueMatch = issueNumberValue . toString ( ) . match ( / \d + / ) ;
229+ if ( issueMatch ) {
230+ responses . push ( {
231+ issueNumber : issueMatch [ 0 ] ,
232+ timestamp : row [ 0 ] || '' ,
233+ } ) ;
234+ console . log (
235+ ` Found RCA for issue #${ issueMatch [ 0 ] } submitted on ${ row [ 0 ] } ` ,
236+ ) ;
237+ }
238+ }
239+ }
240+ return responses ;
241+ }
213242
214243 const responses : RcaFormResponse [ ] = [ ] ;
215244 for ( let i = 1 ; i < rows . length ; i ++ ) {
@@ -220,8 +249,8 @@ async function fetchRcaResponses(sheets: any): Promise<RcaFormResponse[]> {
220249 continue ;
221250 }
222251
223- // Get issue number from column E (index 4)
224- const issueNumberValue = row [ ISSUE_NUMBER_COLUMN ] ;
252+ // Get issue number from dynamically determined column
253+ const issueNumberValue = row [ issueNumberColumnIndex ] ;
225254
226255 if ( issueNumberValue ) {
227256 // Extract just the numeric part from the issue number
@@ -243,8 +272,11 @@ async function fetchRcaResponses(sheets: any): Promise<RcaFormResponse[]> {
243272 }
244273
245274 return responses ;
246- } catch ( error ) {
247- console . error ( 'Error fetching Google Sheets data:' , error ) ;
275+ } catch ( error : any ) {
276+ console . error (
277+ 'Error fetching Google Sheets data:' ,
278+ error ?. message || error ,
279+ ) ;
248280 throw error ;
249281 }
250282}
@@ -315,10 +347,10 @@ async function removeLabelFromIssue(
315347 issue_number : issueNumber ,
316348 name : labelName ,
317349 } ) ;
318- } catch ( error ) {
350+ } catch ( error : any ) {
319351 // If label doesn't exist on issue, the API will throw 404
320352 // This is not an error for our use case, so we can safely ignore it
321- if ( error . status !== 404 ) {
353+ if ( error ? .status !== 404 ) {
322354 throw error ;
323355 }
324356 }
0 commit comments