This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy to Elastic Beanstalk on S3 Upload | ||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- 'src/app_versions/**' | ||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v2 | ||
- name: Upload zip file to S3 | ||
uses: aws-actions/amazon-s3-upload@v2 | ||
with: | ||
bucket-name: elasticbeanstalk-${{ env.AWS_REGION }}-${{ secrets.DEV_ACCOUNT_ID }} | ||
object-key: app-${{ github.sha }}.zip | ||
file-path: src/app_versions/app-${{ github.sha }}.zip | ||
env: | ||
AWS_ACCESS_KEY_ID: ${{ secrets.DEV_AWS_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.DEV_AWS_SECRET_ACCESS_KEY }} | ||
AWS_ACCOUNT_ID: ${{ secrets.DEV_ACCOUNT_ID }} | ||
AWS_REGION: us-east-1 | ||
- name: Create Elastic Beanstalk Application Version | ||
id: create_app_version | ||
uses: aws-actions/aws-elastic-beanstalk-application-version@v1 | ||
with: | ||
application-name: LambdaWebApp2 | ||
version-label: v-$(date +%Y-%m-%d-%H-%M-%S) | ||
source-bundle: s3://elasticbeanstalk-${{ env.AWS_REGION }}-${{ secrets.DEV_ACCOUNT_ID }}/app-${{ github.sha }}.zip | ||
region: us-east-1 | ||
- name: Get Beanstalk Environment Name | ||
uses: aws-actions/aws-cli@v2 | ||
with: | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
region: us-east-1 # Replace with your AWS region | ||
command: aws elasticbeanstalk describe-environments --output text | grep EnvironmentName: | awk '{print $2}' | ||
outputs: | ||
environment_name: ${{ steps.get_env_name.outputs.stdout }} | ||
- name: Deploy Application Version to Elastic Beanstalk | ||
uses: aws-actions/aws-elastic-beanstalk-deploy@v1 | ||
with: | ||
application-name: LambdaWebApp2 | ||
environment-name: ${{ steps.get_env_name.outputs.environment_name }} | ||
version-label: ${{ steps.create_app_version.outputs.version-label }} | ||
region: us-east-1 |