@@ -2607,10 +2607,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
2607
2607
result [ "default" ] = mod ;
2608
2608
return result ;
2609
2609
} ;
2610
+ var __importDefault = ( this && this . __importDefault ) || function ( mod ) {
2611
+ return ( mod && mod . __esModule ) ? mod : { "default" : mod } ;
2612
+ } ;
2610
2613
Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
2611
2614
const core = __importStar ( __webpack_require__ ( 470 ) ) ;
2612
2615
const exec = __importStar ( __webpack_require__ ( 986 ) ) ;
2613
2616
const setupGcloud = __importStar ( __webpack_require__ ( 994 ) ) ;
2617
+ const fs_1 = __importDefault ( __webpack_require__ ( 747 ) ) ;
2614
2618
exports . GCLOUD_METRICS_ENV_VAR = 'CLOUDSDK_METRICS_ENVIRONMENT' ;
2615
2619
exports . GCLOUD_METRICS_LABEL = 'github-actions-deploy-appengine' ;
2616
2620
function run ( ) {
@@ -2619,11 +2623,27 @@ function run() {
2619
2623
try {
2620
2624
// Get action inputs.
2621
2625
let projectId = core . getInput ( 'project_id' ) ;
2626
+ const cwd = core . getInput ( 'working_directory' ) ;
2622
2627
const deliverables = core . getInput ( 'deliverables' ) ;
2623
2628
const imageUrl = core . getInput ( 'image_url' ) ;
2624
2629
const version = core . getInput ( 'version' ) ;
2625
2630
const promote = core . getInput ( 'promote' ) ;
2626
2631
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
+ }
2627
2647
// Install gcloud if not already installed.
2628
2648
if ( ! setupGcloud . isInstalled ( ) ) {
2629
2649
const gcloudVersion = yield setupGcloud . getLatestGcloudSDKVersion ( ) ;
@@ -2648,12 +2668,7 @@ function run() {
2648
2668
}
2649
2669
const toolCommand = setupGcloud . getToolCommand ( ) ;
2650
2670
// 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 ] ;
2657
2672
// Add gcloud flags.
2658
2673
if ( projectId !== '' ) {
2659
2674
appDeployCmd . push ( '--project' , projectId ) ;
@@ -11512,7 +11527,30 @@ function parseServiceAccountKey(serviceAccountKey) {
11512
11527
if ( ! serviceAccountKey . trim ( ) . startsWith ( '{' ) ) {
11513
11528
serviceAccount = Buffer . from ( serviceAccountKey , 'base64' ) . toString ( 'utf8' ) ;
11514
11529
}
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
+ }
11516
11554
}
11517
11555
exports . parseServiceAccountKey = parseServiceAccountKey ;
11518
11556
/**
0 commit comments