Using Github Actions

The Django Easystart project comes with a pre-configured GitHub Actions workflow that allows for building, testing, and deploying the application to Heroku. The workflow is defined in a file called docker_build_and_test.yml located in the .github/workflows directory. This workflow is triggered whenever a pull request is opened, edited, synchronized, or closed on the main branch.

The workflow consists of two jobs:

  1. build-and-runtests: is responsible for building the Docker container, running code quality checks and tests, and generating a code coverage report.

  2. deploy-to-heroku: it deploys the application to Heroku if there are new changes merged into the main branch.

The workflow is triggered when there are new pull requests opened, edited, synchronized, or closed on the main branch.

build-and-runtests

This job runs on the latest version of Ubuntu and performs the following steps:

  1. checkout - checks out the repository code to the runner machine.

  2. build - builds a Docker container based on the Dockerfile.prod file located in the compose/django directory.

  3. code_quality_flake8 - checks the code quality using flake8.

  4. code_quality_black - checks the code style using Black.

  5. code_quality_isort - checks the import order using isort.

  6. tests - runs the tests using pytest and generates a coverage report.

deploy-to-heroku

The job runs on the latest version of Ubuntu and performs the following steps:

  1. deploy-checkout - checks out the repository code to the runner machine.

  2. deploy - deploys the application to Heroku using the Heroku Deploy GitHub Action.

  3. Sends a Slack notification to notify the team about the deployment status.

The workflow is also configured to send Slack notifications to the team about the status of the job, including the repository name, message, commit, author, action, event name, ref, workflow, job, and duration. The Slack webhook URL is stored in the SLACK_WEBHOOK_URL secret on GitHub.