Github action was released by Github as a feature to enable automation and customization of the development to deployment workflows for software development teams. Github actions ease the flow of execution, testing and possibly deployment of repository residing on Github. Also, Github actions provide the flexibility of creating custom flows and steps that are available in standards Continuous Integration (CI) and Continuous Deployment (CD) solutions.
Additionally, using Github actions,process or flow of reviewing codes, triaging issues and managing repository branches and updating dependent libraries in projects become very easy and seamless. The full release note and information is available here
Deploying Django To Google App Engine.
Let's explore how Github actions can be used to automate deployment of a Django application hosted on Github to Google App Engine. There are different approaches to setting up Github actions for your repository and a repository can have multiple actions setup and hooked to different events. A Github action could be set up to listen to pull request merge events to a main branch, and then proceed to build, test and deploy to any of the cloud providers of choice.
In order to ensure a Django app can be deployed from Github to Google app engine, there are certain considerations and setup procedures. The root folder of your Django application should contain the following files main.py, requirements.txt and app.yaml
See a sample App.yaml file below
# App.yaml file
# This configures Google App Engine to serve the files in the app's static
- url: /static
# This handler routes all requests not caught above to your main app. It is
# required when static routes are defined, but can be omitted (along with
# the entire handlers section) when there are no static files defined.
- url: /.*
Then proceed to create .github/workflows folder in your repository root folder and create a github action to subscribe to the push event on the main branch, see the sample action file below.
branches: [ main]
- uses: actions/checkout@v1
- uses: actions-hub/gcloud@master
args: app deploy ./app.yaml
The github action posted above has depends on two other actions, the first to checkout the latest code and then deploy the Django app to Google app engine, using the credentials and project id that can be set in Github secrets.