Search code examples
djangoamazon-web-servicesamazon-elastic-beanstalkgithub-actions

Github actions deploy django application to elastic beanstalk


I'm simply trying to deploy my django application to elastic beanstalk using github actions but keep getting these error:

Warning: Environment update finished, but health is Red and health status is Degraded. Giving it 30 seconds to recover...
Warning: Environment still has health: Red and health status Degraded. Waiting 19 more seconds before failing...
Warning: Environment still has health: Red and health status Degraded. Waiting 8 more seconds before failing...
Error: Deployment failed: Error: Environment still has health Red 30 seconds after update finished!

This it the code I'm using below:

name: AWS Deploy
on:
  push:
    branches:
      - test-main-branch

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout source code
        uses: actions/checkout@v2

  - name: Generate deployment package
    run: zip -r deploy.zip . -x '*.git*'

  - name: Get timestamp
    uses: gerred/actions/current-time@master
    id: current-time

  - name: Run string replace
    uses: frabert/replace-string-action@master
    id: format-time
    with:
      pattern: '[:\.]+'
      string: "${{ steps.current-time.outputs.time }}"
      replace-with: "-"
      flags: "g"

  - name: Deploy to EB
    uses: einaregilsson/beanstalk-deploy@v20
    with:
      aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }}
      aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
      application_name: project-pit
      environment_name: project-pit-cloud
      version_label: 12345
      region: ap-southeast-2
      deployment_package: deploy.zip

  - name: Deployed!
    run: echo App deployed

The application is showing up in my s3 bucket but I still get a Degraded health in on my elastic beanstalk.

I should also mention that my s3 bucket is more than one level deep, bucket/project-pit


Solution

  •     uses: einaregilsson/beanstalk-deploy@v20
        with:
          aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }}
          aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
          application_name: project-pit
          environment_name: project-pit-cloud
          version_label: 12345
          region: ap-southeast-2
          deployment_package: deploy.zip
          wait_for_environment_recovery: 60
    

    wait_for_environment_recovery is an environment variable that sets how long to wait for the state of the Elastic Beanstalk instance to recover.

    The default value is 30.