Skip to content

Commit

Permalink
Allow 'use_existing_version_if_available' to signal that an upload on…
Browse files Browse the repository at this point in the history
…ly action should result in a no-op if the version already exists.
  • Loading branch information
Einar Egilsson committed Dec 1, 2021
1 parent 59ced88 commit 2fcd415
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
run: zip -r deploy.zip . -x '*.git*'

- name: Deploy to EB
uses: einaregilsson/beanstalk-deploy@v18
uses: einaregilsson/beanstalk-deploy@v19
with:
aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
Expand All @@ -48,7 +48,7 @@ attempt to deploy that. In the example below the action would attempt to deploy

```yaml
- name: Deploy to EB
uses: einaregilsson/beanstalk-deploy@v18
uses: einaregilsson/beanstalk-deploy@v19
with:
aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ inputs:
description: 'Whether the action should skip creating a new bucket and use the given one to upload the deployment package to instead. When omitted the actions will (try to) create a new one during deployment.'
required: false
use_existing_version_if_available:
description: 'If set to "true" then the action will deploy an existing version with the given version_label if it already exists, but otherwise create the version and deploy it.'
description: 'If set to "true" then the action will deploy an existing version with the given version_label if it already exists, but otherwise create the version and deploy it. If set to true for an action with no environment name it will upload a version if it does not exist already, but do nothing if the version already exists.'
required: false
wait_for_deployment:
description: 'Whether the action should wait for the deployment to finish and log status messages during the wait. Default is "true". If set to "false" the action will start the deployment on Beanstalk and then exit.'
Expand Down
9 changes: 7 additions & 2 deletions beanstalk-deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,13 @@ function main() {
if (versionAlreadyExists) {

if (!environmentName) {
console.log(`No environment set, but the version ${versionLabel} was found - exiting successfully with no change`);
process.exit(0);
if (useExistingVersionIfAvailable) {
console.log(`No environment set, but the version ${versionLabel} was found and "use_existing_version_if_available" is set to "true" - exiting successfully with no change`);
process.exit(0);
} else {
console.error(`You have no environment set, so we are trying to only create version ${versionLabel}, but it already exists in Beanstalk and the parameter "use_existing_version_if_available" is not set to "true". If you want this to result in a no-op when the version already exists you must set "use_existing_version_if_available" to "true"`);
process.exit(2);
}
} else if (file && !useExistingVersionIfAvailable) {
console.error(`Deployment failed: Version ${versionLabel} already exists. Either remove the "deployment_package" parameter to deploy existing version, or set the "use_existing_version_if_available" parameter to "true" to use existing version if it exists and deployment package if it doesn't.`);
process.exit(2);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "beanstalk-deploy",
"version": "18.0.0",
"version": "19.0.0",
"description": "GitHub Action + command line tool to deploy to AWS Elastic Beanstalk.",
"main": "beanstalk-deploy.js",
"scripts": {
Expand Down

0 comments on commit 2fcd415

Please sign in to comment.