From f91f103fbd1ed34a1b7fde79f3cb19690aebe5d7 Mon Sep 17 00:00:00 2001 From: Oli Date: Tue, 18 Apr 2023 07:27:26 +0100 Subject: [PATCH] fix: deploy weather service on update --- .github/workflows/release.yml | 29 ++++++- .releaserc.yaml | 4 +- services/weather_service.yaml | 95 +++++++++++++++++++++++ service.yaml => services/web_service.yaml | 0 4 files changed, 124 insertions(+), 4 deletions(-) create mode 100644 services/weather_service.yaml rename service.yaml => services/web_service.yaml (100%) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a03c82d..d7fad44 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -60,7 +60,8 @@ jobs: ALLOWED_HOSTS: 127.0.0.1 CSRF_TRUSTED_ORIGINS: http://127.0.0.1 - deploy: + deploy-web-service: + name: Deploy Web Service runs-on: ubuntu-20.04 needs: [migrate, gcr-push] steps: @@ -81,4 +82,28 @@ jobs: uses: google-github-actions/deploy-cloudrun@v1 with: region: europe-west1 - metadata: ./service.yaml + metadata: ./services/web_service.yaml + + deploy-weather-cron: + name: Deploy Weather Cron Job + runs-on: ubuntu-20.04 + needs: [migrate, gcr-push] + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Install Ubuntu packages + run: | + sudo DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + libgdal26 + - id: auth + name: Authenticate to Google Cloud + uses: google-github-actions/auth@v1 + with: + credentials_json: ${{ secrets.GCLOUD_SERVICE_KEY }} + + - id: deploy + name: Deploy to GCR + uses: google-github-actions/deploy-cloudrun@v1 + with: + region: europe-west1 + metadata: ./services/weather_service.yaml \ No newline at end of file diff --git a/.releaserc.yaml b/.releaserc.yaml index 5893c30..4ca8c00 100644 --- a/.releaserc.yaml +++ b/.releaserc.yaml @@ -18,11 +18,11 @@ plugins: numReplacements: 1 countMatches: true - files: - - "service.yaml" + - "web_service.yaml" from: "gcr.io/garden-server-381815/garden-server:.*" to: "gcr.io/garden-server-381815/garden-server:${nextRelease.version}" results: - - file: "service.yaml" + - file: "web_service.yaml" hasChanged: true diff --git a/services/weather_service.yaml b/services/weather_service.yaml new file mode 100644 index 0000000..6a69b28 --- /dev/null +++ b/services/weather_service.yaml @@ -0,0 +1,95 @@ +apiVersion: run.googleapis.com/v1 +kind: Job +metadata: + name: garden-server + namespace: '400668159616' + selfLink: /apis/run.googleapis.com/v1/namespaces/400668159616/jobs/garden-server + uid: 28632f04-2e89-4236-b8b9-8576a54351f5 + resourceVersion: AAX5lghBBZM + generation: 7 + creationTimestamp: '2023-04-17T06:03:52.644269Z' + labels: + cloud.googleapis.com/location: europe-west1 + run.googleapis.com/lastUpdatedTime: '2023-04-17T08:27:06.512391Z' + annotations: + run.googleapis.com/client-name: cloud-console + run.googleapis.com/lastModifier: oli.edmund.parker@gmail.com + client.knative.dev/user-image: gcr.io/garden-server-381815/garden-server:1.4.5 # x-release-please-version + run.googleapis.com/creator: oli.edmund.parker@gmail.com + run.googleapis.com/operation-id: f9c1acaa-196a-4913-9488-2a633a6ddebc +spec: + template: + metadata: + annotations: + run.googleapis.com/client-name: cloud-console + client.knative.dev/user-image: gcr.io/garden-server-381815/garden-server:1.4.5 # x-release-please-version + run.googleapis.com/execution-environment: gen2 + spec: + parallelism: 1 + taskCount: 1 + template: + spec: + containers: + - image: gcr.io/garden-server-381815/garden-server:1.4.5 # x-release-please-version + command: + - ./manage.py + - populate_weather + env: + - name: DJANGO_SETTINGS_MODULE + valueFrom: + secretKeyRef: + key: latest + name: DJANGO_SETTINGS_MODULE + - name: DJANGO_DATABASE_PASSWORD + valueFrom: + secretKeyRef: + key: latest + name: DJANGO_DATABASE_PASSWORD + - name: DJANGO_DATABASE_HOST + valueFrom: + secretKeyRef: + key: latest + name: DJANGO_DATABASE_HOST + - name: DJANGO_DATABASE_NAME + valueFrom: + secretKeyRef: + key: latest + name: DJANGO_DATABASE_NAME + - name: CSRF_TRUSTED_ORIGINS + valueFrom: + secretKeyRef: + key: latest + name: CSRF_TRUSTED_ORIGINS + - name: ALLOWED_HOST + valueFrom: + secretKeyRef: + key: latest + name: ALLOWED_HOST + - name: SECRET_KEY + valueFrom: + secretKeyRef: + key: latest + name: SECRET_KEY + - name: DJANGO_DATABASE_USER + valueFrom: + secretKeyRef: + key: latest + name: DJANGO_DATABASE_USER + resources: + limits: + cpu: 1000m + memory: 512Mi + maxRetries: 0 + timeoutSeconds: '600' + serviceAccountName: 400668159616-compute@developer.gserviceaccount.com +status: + observedGeneration: 7 + conditions: + - type: Ready + status: 'True' + lastTransitionTime: '2023-04-17T06:03:53.219778Z' + executionCount: 27 + latestCreatedExecution: + name: garden-server-mfm8r + completionTimestamp: '2023-04-18T06:01:01.535013Z' + creationTimestamp: '2023-04-18T06:00:00.769788Z' diff --git a/service.yaml b/services/web_service.yaml similarity index 100% rename from service.yaml rename to services/web_service.yaml