Using GitHub Actions to deploy to Elastic Beanstalk - Amazon Elastic Beanstalk
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Using GitHub Actions to deploy to Elastic Beanstalk

GitHub Actions can automatically deploy your application to Elastic Beanstalk when you push code changes to your repository. The Elastic Beanstalk Deploy action provides a simple YAML interface that handles creating application versions, uploading source bundles to Amazon S3, and deploying to your Elastic Beanstalk environment.

Example workflow

The following example workflow deploys an application to an Elastic Beanstalk environment each time you push to the main branch. Create a .yml file in your repository under .github/workflows/ .

Example GitHub Actions workflow for Elastic Beanstalk deployment
name: Deploy to Elastic Beanstalk on: push: branches: - main permissions: id-token: write contents: read jobs: deploy: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v4 with: role-to-assume: arn:aws:iam::123456789012:role/my-github-actions-role aws-region: us-east-1 - name: Deploy to Elastic Beanstalk uses: aws-actions/aws-elasticbeanstalk-deploy@v1.0.0 with: aws-region: us-east-1 application-name: my-application environment-name: my-application-env

This workflow checks out your repository, uses OpenID Connect (OIDC) to authenticate with Amazon through the Configure Amazon Credentials action, and then deploys your application to Elastic Beanstalk. The deploy action packages your repository contents, uploads the source bundle to Amazon S3, creates a new application version, and creates or updates your environment. By default, it waits for the deployment to complete and the environment to return to a healthy state.

For more configuration options and advanced examples, see the Elastic Beanstalk Deploy action README on GitHub.

Additional resources