-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
76 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
name: "Migrate Django database in Cloud Run" | ||
|
||
on: | ||
workflow_call: # Allow this workflow to be called by other workflows | ||
secrets: | ||
DATABASE_URL: | ||
required: true | ||
GCP_CLOUD_CONNECTION_NAME: | ||
required: true | ||
GCP_IAM_SA_CREDENTIALS: | ||
required: true | ||
|
||
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@v4 | ||
with: | ||
path: ~/.cache/pypoetry/virtualenvs | ||
key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }} | ||
|
||
- run: poetry --version | ||
|
||
- name: Install poetry dependencies | ||
run: poetry install | ||
|
||
# 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 | ||
env: | ||
DATABASE_URL: ${{ secrets.DATABASE_URL }} | ||
run: poetry run python manage.py migrate --plan |
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
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