Skip to content

Try it out

Try it out #5

Workflow file for this run

name: "Migrate Django database in Cloud Run"
on:
push:
branches:
- main
- auto-migrate-and-auto-deploy
env:
AR_REGION: "us"
PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
REPOSITORY: ${{ secrets.GCP_AR_REPO_NAME }}
SERVICE: ${{ secrets.GCP_SERVICE_NAME }}
SERVICE_REGION: "us-central1"
jobs:
migrate:
runs-on: "ubuntu-latest"
defaults:
run:
working-directory: ./bloom_nofos
permissions:
contents: "read"
id-token: "write"
steps:
- name: "Checkout"
uses: "actions/checkout@v4"
- name: "Set up Python"
uses: actions/setup-python@v4
with:
python-version: "3.11.9"
- name: "Set up poetry"
uses: Gr1N/setup-poetry@v8
- uses: actions/cache@v2
with:
path: ~/.cache/pypoetry/virtualenvs
key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}
- run: poetry --version
# Configure auth with Service Account with permissions to build and deploy on Google Cloud
- id: "auth"
name: "Authenticate to Google Cloud"
uses: "google-github-actions/auth@v2"
with:
credentials_json: ${{ secrets.GCP_IAM_SA_CREDENTIALS }}
# BEGIN - Django migration (if needed)
# sudo mv cloud-sql-proxy /usr/local/bin/
- name: "Install Cloud SQL Auth Proxy"
run: |
curl -o cloud-sql-proxy https://storage.googleapis.com/cloud-sql-connectors/cloud-sql-proxy/v2.14.0/cloud-sql-proxy.linux.amd64
chmod +x cloud-sql-proxy
./cloud-sql-proxy ${{ secrets.GCP_CLOUD_CONNECTION_NAME }} &
- name: Run migration
run: poetry run python manage.py migrate --plan