Skip to content

Commit

Permalink
dispatch (#14)
Browse files Browse the repository at this point in the history
* initial

* update sso cron jobs

* run django and sso server

* tidy up

* set sso service env vars

* format on save and organize imports

* Merge branch 'main' into dispatch

* use subpaths for portal
  • Loading branch information
SKairinos authored Sep 26, 2023
1 parent bf09697 commit 3a08b61
Show file tree
Hide file tree
Showing 4 changed files with 147 additions and 7 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/dispatch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Dispatch

on:
push:
branches:
- main
paths:
- 'dispatch.yaml'
workflow_dispatch:

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: 🛫 Checkout
uses: actions/checkout@v3

- name: 🗝 Authenticate with GCloud
uses: google-github-actions/auth@v1
with:
credentials_json: ${{ secrets.GCP_CREDENTIALS }}

- name: 🤖 Set up GCloud SDK
uses: google-github-actions/setup-gcloud@v1

- name: 🚀 Deploy Cron Jobs on GCloud
run: gcloud app deploy dispatch.yaml
62 changes: 61 additions & 1 deletion codeforlife.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,18 @@
"settings": {
"python.terminal.activateEnvironment": false,
"files.exclude": {
"**/__pycache__": true
"**/__pycache__": true,
"**/.pytest_cache": true,
"**/.hypothesis": true
},
"editor.tabSize": 2,
"editor.rulers": [
80
],
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true
},
"workbench.colorCustomizations": {
"editorRuler.foreground": "#008000"
},
Expand Down Expand Up @@ -104,6 +110,60 @@
"program": "${file}",
"console": "integratedTerminal",
"justMyCode": true
},
{
"name": "Django Server (+SSO)",
"type": "python",
"request": "launch",
"django": true,
"justMyCode": false,
"program": "${fileWorkspaceFolder}/backend/manage.py",
"args": [
"runserver",
"localhost:8000"
],
"preLaunchTask": "run-sso-server"
}
]
},
"tasks": {
"version": "2.0.0",
"tasks": [
{
"label": "install-dev-deps",
"type": "shell",
"options": {
"cwd": "${fileWorkspaceFolder}/backend"
},
"command": "pipenv install --dev"
},
{
"label": "migrate-db",
"type": "shell",
"options": {
"cwd": "${fileWorkspaceFolder}/backend"
},
"dependsOn": [
"install-dev-deps"
],
"command": "pipenv run python ./manage.py migrate"
},
{
"label": "run-sso-server",
"type": "shell",
"isBackground": true,
"options": {
"cwd": "${workspaceFolder}/codeforlife-sso/backend",
"env": {
"DB_NAME": "${fileWorkspaceFolder}/backend/db.sqlite3",
"SERVICE_NAME": "sso",
"SERVICE_PORT": "8001"
}
},
"dependsOn": [
"migrate-db"
],
"command": "pipenv run python ./manage.py runserver localhost:8001"
}
]
}
Expand Down
12 changes: 6 additions & 6 deletions cron.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,20 @@ cron:

# /api/cron/session/clear-expired/

- url: /api/cron/session/clear-expired/
- url: /development-sso/api/session/clear-expired/
schedule: every day 00:00
timezone: Europe/London
target: development-portal
target: development-sso

- url: /api/cron/session/clear-expired/
- url: /staging-sso/api/session/clear-expired/
schedule: every day 00:00
timezone: Europe/London
target: staging-portal
target: staging-sso

- url: /api/cron/session/clear-expired/
- url: /sso/api/session/clear-expired/
schedule: every day 00:00
timezone: Europe/London
target: production-portal
target: production-sso

# /api/cron/user/unverified/send-first-reminder/

Expand Down
53 changes: 53 additions & 0 deletions dispatch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# https://cloud.google.com/appengine/docs/legacy/standard/python/reference/dispatch-yaml
dispatch:
# SSO

- url: "codeforlife.education/development-sso/*"
service: development-sso

- url: "codeforlife.education/staging-sso/*"
service: staging-sso

- url: "codeforlife.education/sso/*"
service: production-sso

# Portal

- url: "codeforlife.education/development-portal/*"
service: development-portal

- url: "codeforlife.education/staging-portal/*"
service: staging-portal

- url: "codeforlife.education/portal/*"
service: production-portal

# TODO: route to new portal service.
- url: "codeforlife.education/*"
service: default

# TODO: route to new portal service.
- url: "www.codeforlife.education/*"
service: default

# Rapid Router

# - url: "development-rapid-router.codeforlife.education/*"
# service: development-rapid-router

# - url: "staging-rapid-router.codeforlife.education/*"
# service: staging-rapid-router

# - url: "rapid-router.codeforlife.education/*"
# service: production-rapid-router

# Kurono

# - url: "development-kurono.codeforlife.education/*"
# service: development-kurono

# - url: "staging-kurono.codeforlife.education/*"
# service: staging-kurono

# - url: "kurono.codeforlife.education/*"
# service: production-kurono

0 comments on commit 3a08b61

Please sign in to comment.