deploy to EBS from github

GitHub Actions provide an easier way to implement CI/CD for the projects. With a single YAML file and a little bit of configuration, one could achieve a CD pipeline.

For Elastic BeanStalk, we need to run the jobs in a Linux container. ubuntu works in most of the cases. If you wish to use Alpine, you can test it out.

Following workflow runs on push event (git push ...) to the repository's main branch. You can modify it with other events such as pull_request etc. (Full List of Events)

The env variables secrets.AWS_ACCESS_KEY_ID and secrets.AWS_SECRET_ACCESS_KEY must be set in the repository. Visit to set those variables.

Finally, create a file .github/workflows/deploy.yml and paste the following content.

name: Deploy to Beanstalk

    - main

    runs-on: ubuntu-latest

    - name: get source code
      uses: actions/checkout@v2

    - name: zip deployment code
      run: zip -r . -x '*.git*'

    - name: deploy to beanstalk
      uses: einaregilsson/beanstalk-deploy@v20
        aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }}
        aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
        application_name:  <EBS_APPLICATION_NAME>
        environment_name: <EBS_APPLICATION_ENV>
        region: <AWS_REGION>
        version_label: ${{ github.run_number }} # or a custom version number
        existing_bucket_name: <AWS_S3_BUCKET_NAME> # stores