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:
build-and-runtests: is responsible for building the Docker container, running code quality checks and tests, and generating a code coverage report.
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:
checkout - checks out the repository code to the runner machine.
build - builds a Docker container based on the Dockerfile.prod file located in the compose/django directory.
code_quality_flake8 - checks the code quality using flake8.
code_quality_black - checks the code style using Black.
code_quality_isort - checks the import order using isort.
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:
deploy-checkout - checks out the repository code to the runner machine.
deploy - deploys the application to Heroku using the Heroku Deploy GitHub Action.
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.