Skip to content

Google App Engine Deployment #119

Google App Engine Deployment

Google App Engine Deployment #119

# Based on https://github.com/actions/starter-workflows/blob/main/ci/django.yml
name: Google App Engine Deployment
on:
# CI must pass on the master branch
workflow_run:
workflows: ["Continuous Integration"]
branches: [master]
types:
- completed
env:
PYTHON_TARGET: 3.11
# Django
DJANGO_SETTINGS_MODULE: tcf_core.settings.prod
SECRET_KEY: ${{ secrets.SECRET_KEY }}
DEBUG: 0
# database
DB_NAME: ${{ secrets.DB_NAME }}
DB_USER: ${{ secrets.DB_USER }}
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
DB_HOST: ${{ secrets.DB_HOST }}
DB_PORT: ${{ secrets.DB_PORT }}
# social-auth-app-django
SOCIAL_AUTH_GOOGLE_OAUTH2_KEY: ${{ secrets.SOCIAL_AUTH_GOOGLE_OAUTH2_KEY }}
SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET: ${{ secrets.SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET }}
# email for account verification
EMAIL_HOST_USER: ${{ secrets.EMAIL_HOST_USER }}
EMAIL_HOST_PASSWORD: ${{ secrets.EMAIL_HOST_PASSWORD }}
# review drive account information
REVIEW_DRIVE_ID: ${{ secrets.REVIEW_DRIVE_ID }}
REVIEW_DRIVE_EMAIL: ${{ secrets.REVIEW_DRIVE_EMAIL }}
REVIEW_DRIVE_PASSWORD: ${{ secrets.REVIEW_DRIVE_PASSWORD }}
jobs:
deploy:
# if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
steps:
# A workaround because this workflow runs on the default branch (`dev`)
# because that's how `workflow_run` works at the moment
# https://github.community/t/workflow-run-not-working-as-expected/139342
- name: Checkout `master`
uses: actions/checkout@v2
with:
ref: ${{ github.event.workflow_run.head_sha }}
- name: Set up Python ${{ env.PYTHON_TARGET }}
uses: actions/setup-python@v2
with:
python-version: ${{ env.PYTHON_TARGET }}
- name: Install Python packages, excluding the unnecessary ones
run: |
python -m pip install --upgrade pip
sed -i '/\(coverage\|lint\|types\-tqdm\|mypy\|black\|isort\|gunicorn\|django\-heroku\|django\-stubs\)/d' requirements.txt
pip install -r requirements.txt
- name: Migrations
run: |
python manage.py migrate
- name: Set up Google Cloud SDK
uses: google-github-actions/setup-gcloud@v0
with:
service_account_key: ${{ secrets.GCP_SA_KEY }}
export_default_credentials: true
- name: Collect static files
run: python3 manage.py collectstatic --noinput --clear
- name: Substitute environment variables
run: envsubst < .config/app.yaml.template > app.yaml
- name: Deploy to Google App Engine
uses: google-github-actions/deploy-appengine@main
with:
project_id: ${{ secrets.GCP_PROJECT_ID }}