@@ -6,8 +6,10 @@ import { context, getOctokit } from '@actions/github';
66// @ts -ignore - googleapis types may not be available locally
77import { google } from 'googleapis' ;
88
9- // HTTP status codes
10- const HTTP_NOT_FOUND = 404 ;
9+ // HTTP status codes enum for better maintainability
10+ enum HttpStatusCode {
11+ NotFound = 404 ,
12+ }
1113
1214interface Label {
1315 name : string ;
@@ -21,12 +23,23 @@ const RCA_NEEDED_LABEL: Label = {
2123 description : 'Issue requires Root Cause Analysis' ,
2224} ;
2325
26+ // Type alias for Google Sheets v4 API
27+ // @ts -ignore - googleapis types may not be available locally
28+ type SheetsV4 = ReturnType < typeof google . sheets > ;
29+
2430// Google Sheets configuration from environment variables
2531// @ts -ignore - process is available at runtime in GitHub Actions
2632const SPREADSHEET_ID = process . env . SPREADSHEET_ID ;
2733// @ts -ignore - process is available at runtime in GitHub Actions
2834const SHEET_NAME = process . env . SHEET_NAME ;
2935
36+ /**
37+ * Represents a single response row from the RCA (Root Cause Analysis) Google Form.
38+ * @property issueNumber - The GitHub issue number associated with this RCA response (as a string)
39+ * @property timestamp - The timestamp when the form was submitted
40+ * @property [key: string] - Any additional form fields captured from the Google Form.
41+ * The keys correspond to column headers in the Google Sheet, and the values are the user responses.
42+ */
3043interface RcaFormResponse {
3144 issueNumber : string ;
3245 timestamp : string ;
@@ -209,10 +222,6 @@ async function main(): Promise<void> {
209222 }
210223}
211224
212- // Type alias for Google Sheets v4 API
213- // @ts -ignore - googleapis types may not be available locally
214- type SheetsV4 = ReturnType < typeof google . sheets > ;
215-
216225async function initializeGoogleSheets ( credentials : string ) : Promise < SheetsV4 > {
217226 // Decode base64 credentials
218227 const credentialsJson = JSON . parse (
@@ -373,7 +382,7 @@ async function removeLabelFromIssue(
373382 } catch ( error : any ) {
374383 // If label doesn't exist on issue, the API will throw 404
375384 // This is not an error for our use case, so we can safely ignore it
376- if ( error ?. status !== HTTP_NOT_FOUND ) {
385+ if ( error ?. status !== HttpStatusCode . NotFound ) {
377386 throw error ;
378387 }
379388 }
0 commit comments