From 7be69733dc17d23d8510ca9b8c3732a7983a3f76 Mon Sep 17 00:00:00 2001 From: Ryan McCahan Date: Mon, 27 Mar 2023 10:50:40 -0600 Subject: [PATCH 1/2] Support other env vars in CLI version --- README.md | 8 ++++++++ beanstalk-deploy.js | 23 ++++++++++++----------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index df21242..ea1d1ae 100644 --- a/README.md +++ b/README.md @@ -121,6 +121,14 @@ The program is available as an [NPM Package](https://www.npmjs.com/package/beans ```npm install -g beanstalk-deploy``` and then you'll have the ```beanstalk-deploy``` command (without .js) available everywhere. +Some additional environment variables are available to use functionality available in the GitHub Actions version: + +```.bash +export INPUT_EXISTING_BUCKET_NAME=elasticbeanstalk-us-east-1-xxxxxxxxxxxx +export INPUT_WAIT_FOR_DEPLOYMENT=false +export INPUT_WAIT_FOR_ENVIRONMENT_RECOVERY=20 # Wait for 30 seconds for enironment recovery +``` + ## Caveats 1. The S3 upload is a simple PUT request, we don't handle chunked upload. It has worked fine for files that are a diff --git a/beanstalk-deploy.js b/beanstalk-deploy.js index 8521ab8..7a09505 100755 --- a/beanstalk-deploy.js +++ b/beanstalk-deploy.js @@ -258,6 +258,18 @@ function main() { waitForRecoverySeconds = 30, waitUntilDeploymentIsFinished = true; //Whether or not to wait for the deployment to complete... + if (process.env.INPUT_EXISTING_BUCKET_NAME) { + existingBucketName = strip(process.env.INPUT_EXISTING_BUCKET_NAME); + } + + if ((process.env.INPUT_WAIT_FOR_DEPLOYMENT || '').toLowerCase() == 'false') { + waitUntilDeploymentIsFinished = false; + } + + if (process.env.INPUT_WAIT_FOR_ENVIRONMENT_RECOVERY) { + waitForRecoverySeconds = parseInt(process.env.INPUT_WAIT_FOR_ENVIRONMENT_RECOVERY); + } + if (IS_GITHUB_ACTION) { //Running in GitHub Actions application = strip(process.env.INPUT_APPLICATION_NAME); environmentName = strip(process.env.INPUT_ENVIRONMENT_NAME); @@ -271,17 +283,6 @@ function main() { awsApiRequest.sessionToken = strip(process.env.INPUT_AWS_SESSION_TOKEN); awsApiRequest.region = strip(process.env.INPUT_REGION); - if (process.env.INPUT_EXISTING_BUCKET_NAME) { - existingBucketName = strip(process.env.INPUT_EXISTING_BUCKET_NAME); - } - - if ((process.env.INPUT_WAIT_FOR_DEPLOYMENT || '').toLowerCase() == 'false') { - waitUntilDeploymentIsFinished = false; - } - - if (process.env.INPUT_WAIT_FOR_ENVIRONMENT_RECOVERY) { - waitForRecoverySeconds = parseInt(process.env.INPUT_WAIT_FOR_ENVIRONMENT_RECOVERY); - } useExistingVersionIfAvailable = process.env.INPUT_USE_EXISTING_VERSION_IF_AVAILABLE == 'true' || process.env.INPUT_USE_EXISTING_VERSION_IF_AVAILABLE == 'True'; } else { //Running as command line script From 3a49ae5d74a41206df667ec20b4eb71f0e5d3edb Mon Sep 17 00:00:00 2001 From: Ryan McCahan Date: Mon, 27 Mar 2023 15:45:26 -0600 Subject: [PATCH 2/2] Typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ea1d1ae..dacc314 100644 --- a/README.md +++ b/README.md @@ -126,7 +126,7 @@ Some additional environment variables are available to use functionality availab ```.bash export INPUT_EXISTING_BUCKET_NAME=elasticbeanstalk-us-east-1-xxxxxxxxxxxx export INPUT_WAIT_FOR_DEPLOYMENT=false -export INPUT_WAIT_FOR_ENVIRONMENT_RECOVERY=20 # Wait for 30 seconds for enironment recovery +export INPUT_WAIT_FOR_ENVIRONMENT_RECOVERY=20 # Wait for 30 seconds for environment recovery ``` ## Caveats