-
Notifications
You must be signed in to change notification settings - Fork 2
63 lines (50 loc) · 1.68 KB
/
django_migrate.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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