-
Notifications
You must be signed in to change notification settings - Fork 129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to deploy to different ELB environments based on code pushed to branch #5
Comments
I think the best way to do that would be to use - name: Deploy to EB
if: github.ref == 'master'
uses: einaregilsson/beanstalk-deploy@v4
with:
aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
application_name: MyApplicationName
environment_name: prod
version_label: 12345
region: us-west-2
deployment_package: deploy.zip and then have another block for staging. Or, you could use an expression for the environment name, something like: - name: Deploy to EB
uses: einaregilsson/beanstalk-deploy@v4
with:
aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
application_name: MyApplicationName
environment_name: {{ github.ref }}
version_label: 12345
region: us-west-2
deployment_package: deploy.zip Of course, this would only work if your branches were named the same thing as your environments, but you could also just set an environment variable before based on the branches, something like: - run: echo "::set-env name=ENVIRONMENT_NAME::prod"
if: github.ref == 'master'
- run: echo "::set-env name=ENVIRONMENT_NAME::staging"
if: github.ref == 'staging'
# and then
- name: Deploy to EB
uses: einaregilsson/beanstalk-deploy@v4
with:
aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
application_name: MyApplicationName
environment_name: {{ env.ENVIRONMENT_NAME }}
version_label: 12345
region: us-west-2
deployment_package: deploy.zip So that's something to try out. Look at https://help.github.com/en/actions/automating-your-workflow-with-github-actions/contexts-and-expression-syntax-for-github-actions#about-context-and-expressions for more info about expression syntax in GitHub Actions |
Closing this, since it seems to have a reasonable workaround. |
@einaregilsson My concern is how can I deploy my application to different environments on the AWS Beanstalk based on which branch the code is being pushed.
For example - I have two environment
prod
andstaging
having respective branchesmaster
andstaging
. I want to trigger the CI/CD procedure whenever the code is pushed to these branches.The only thing that needs to be taken care of is that when code pushed to staging branch the application should be deployed to staging environment and if pushed to master branch the build for prod environment should be triggered.
Travis CI has the same thing like below:
So, how can I implement the same thing in github action using your action?
The text was updated successfully, but these errors were encountered: