@@ -2607,10 +2607,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
26072607 result [ "default" ] = mod ;
26082608 return result ;
26092609} ;
2610+ var __importDefault = ( this && this . __importDefault ) || function ( mod ) {
2611+ return ( mod && mod . __esModule ) ? mod : { "default" : mod } ;
2612+ } ;
26102613Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
26112614const core = __importStar ( __webpack_require__ ( 470 ) ) ;
26122615const exec = __importStar ( __webpack_require__ ( 986 ) ) ;
26132616const setupGcloud = __importStar ( __webpack_require__ ( 994 ) ) ;
2617+ const fs_1 = __importDefault ( __webpack_require__ ( 747 ) ) ;
26142618exports . GCLOUD_METRICS_ENV_VAR = 'CLOUDSDK_METRICS_ENVIRONMENT' ;
26152619exports . GCLOUD_METRICS_LABEL = 'github-actions-deploy-appengine' ;
26162620function run ( ) {
@@ -2619,11 +2623,27 @@ function run() {
26192623 try {
26202624 // Get action inputs.
26212625 let projectId = core . getInput ( 'project_id' ) ;
2626+ const cwd = core . getInput ( 'working_directory' ) ;
26222627 const deliverables = core . getInput ( 'deliverables' ) ;
26232628 const imageUrl = core . getInput ( 'image_url' ) ;
26242629 const version = core . getInput ( 'version' ) ;
26252630 const promote = core . getInput ( 'promote' ) ;
26262631 const serviceAccountKey = core . getInput ( 'credentials' ) ;
2632+ // Change working directory
2633+ if ( cwd )
2634+ process . chdir ( cwd . trim ( ) ) ;
2635+ // Validate deliverables
2636+ const allDeliverables = deliverables . split ( ' ' ) ;
2637+ if ( allDeliverables [ 0 ] == '' )
2638+ allDeliverables [ 0 ] = 'app.yaml' ;
2639+ for ( const deliverable of allDeliverables ) {
2640+ if ( ! fs_1 . default . existsSync ( deliverable ) ) {
2641+ core . error ( deliverable + ' is not in path.' ) ;
2642+ const message = 'Deliverables can not be found. ' +
2643+ 'Check `working_directory` and `deliverables` input paths.' ;
2644+ throw new Error ( message ) ;
2645+ }
2646+ }
26272647 // Install gcloud if not already installed.
26282648 if ( ! setupGcloud . isInstalled ( ) ) {
26292649 const gcloudVersion = yield setupGcloud . getLatestGcloudSDKVersion ( ) ;
@@ -2648,12 +2668,7 @@ function run() {
26482668 }
26492669 const toolCommand = setupGcloud . getToolCommand ( ) ;
26502670 // Create app engine gcloud cmd.
2651- const appDeployCmd = [
2652- 'app' ,
2653- 'deploy' ,
2654- '--quiet' ,
2655- ...deliverables . split ( ' ' ) ,
2656- ] ;
2671+ const appDeployCmd = [ 'app' , 'deploy' , '--quiet' , ...allDeliverables ] ;
26572672 // Add gcloud flags.
26582673 if ( projectId !== '' ) {
26592674 appDeployCmd . push ( '--project' , projectId ) ;
@@ -11512,7 +11527,30 @@ function parseServiceAccountKey(serviceAccountKey) {
1151211527 if ( ! serviceAccountKey . trim ( ) . startsWith ( '{' ) ) {
1151311528 serviceAccount = Buffer . from ( serviceAccountKey , 'base64' ) . toString ( 'utf8' ) ;
1151411529 }
11515- return JSON . parse ( serviceAccount ) ;
11530+ try {
11531+ return JSON . parse ( serviceAccount ) ;
11532+ }
11533+ catch ( error ) {
11534+ const keyFormat = `
11535+ {
11536+ "type": "service_account",
11537+ "project_id": "project-id",
11538+ "private_key_id": "key-id",
11539+ "private_key": "-----BEGIN PRIVATE KEY-----\\nprivate-key\\n-----END PRIVATE KEY-----\\n",
11540+ "client_email": "service-account-email",
11541+ "client_id": "client-id",
11542+ "auth_uri": "https://accounts.google.com/o/oauth2/auth",
11543+ "token_uri": "https://accounts.google.com/o/oauth2/token",
11544+ "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
11545+ "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/service-account-email"
11546+ }
11547+ ` ;
11548+ const message = 'Error parsing credentials: ' +
11549+ error . message +
11550+ '\nEnsure your credentials are base64 encoded or validate JSON format: ' +
11551+ keyFormat ;
11552+ throw new Error ( message ) ;
11553+ }
1151611554}
1151711555exports . parseServiceAccountKey = parseServiceAccountKey ;
1151811556/**
0 commit comments