Serverless framework plugin to check that current git branch is allowed to deploy to serverless stage.
Add this plugin to your Serverless project following the Install directions below.
Once installed when you run sls deploy --stage STAGE The STAGE will be checked against you config to verify you are on the correct git branch to deploy that stage.
This plugin required both git and the Serverless Framework
Create a folder called .serverless_plugins in the root of your project.
Copy the file check-git-branch-before-deploy.js into that folder.
Update your serverless.yml file with the following:
Add to custom configuration:
custom:
checkGitBranchBeforeDeploy:
staging: staging
production: productionUpdate stage to use variable
provider:
stage: ${opt:stage}Add to plugins list
plugins:
- check-git-branch-before-deployThat's it. You've now protected yourself from deploying dev code to the production stage... maybe. :-)
This project is licensed under the MIT License - see the LICENSE.md file for details
- Hat tip to Antoine Toubhans and his blog post