Skip to content

Django manage

Django manage #4

Workflow file for this run

name: Django manage
on:
workflow_dispatch:
inputs:
collectstatic:
description: Force static collection
required: true
type: boolean
default: false
migrate:
description: Force DB migration
required: true
type: boolean
default: false
migration_params:
description: Specify the app and migration number
required: false
type: string
env:
DEBUG: False
USE_GCS_STATICS: False
defaults:
run:
working-directory: ./alteredbuilder
jobs:
collect_statics:
name: Collect static files into GCS
if: ${{ inputs.collectstatic }}
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Collect static files to GCS
run: python manage.py collectstatic --no-input
env:
SECRET_KEY: ${{ secrets.SECRET_KEY }}
DATABASE_URL: ${{ secrets.MIGRATION_DATABASE_URL }}
USE_GCS_STATICS: True
GCS_BUCKET_STATICS: ${{ vars.GCS_BUCKET_STATICS }}
GCP_GITHUB_SA: ${{ secrets.GCP_GITHUB_SA_JSON }}
migrate_db:
name: Perform db migrations
if: ${{ inputs.migrate}}
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Configure Google Cloud SQL Auth Proxy
uses: mattes/gce-cloudsql-proxy-action@v1
with:
creds: ${{ secrets.GCP_GITHUB_SA_JSON }}
instance: ${{ secrets.CLOUD_SQL_INSTANCE }}
port: 5432
- name: Run migrations
run: python manage.py migrate --no-input ${{ inputs.migration_params }}
env:
SECRET_KEY: ${{ secrets.SECRET_KEY }}
DATABASE_URL: ${{ secrets.MIGRATION_DATABASE_URL }}