Try it out #3
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: | |
deploy: | |
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://dl.google.com/cloudsql/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 |