-
Notifications
You must be signed in to change notification settings - Fork 1
93 lines (93 loc) · 3.32 KB
/
deploy-staging.yaml
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
---
name: Deploy (Staging)
on:
workflow_run:
workflows: [Release Image (Staging)]
branches: [staging]
types: [completed]
jobs:
deploy-staging:
runs-on: ubuntu-latest
if: |
${{ github.event_name == 'workflow_dispatch' }}
|| ${{ github.event.workflow_run.conclusion == 'success' }}
environment:
name: staging
url: https://staging.backend.basedosdados.org
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: staging
- name: Import secrets from Vault
id: import_secrets
uses: hashicorp/[email protected]
with:
url: https://vault.basedosdados.org
token: ${{ secrets.VAULT_TOKEN }}
secrets: |
secret/data/gcp_credentials/basedosdados-dev GCP_PROJECT_ID | GCP_PROJECT_ID ;
secret/data/gcp_credentials/basedosdados-dev GH_ACTIONS_SA | GCP_SA ;
secret/data/gcp_credentials/basedosdados-dev GKE_CLUSTER_NAME | GKE_CLUSTER_NAME ;
secret/data/gcp_credentials/basedosdados-dev GKE_CLUSTER_ZONE | GKE_CLUSTER_ZONE ;
- name: Setup Google Cloud CLI
uses: google-github-actions/[email protected]
with:
service_account_key: ${{ steps.import_secrets.outputs.GCP_SA }}
project_id: ${{ steps.import_secrets.outputs.GCP_PROJECT_ID }}
export_default_credentials: true
- name: Get GKE credentials
uses: google-github-actions/[email protected]
with:
cluster_name: ${{ steps.import_secrets.outputs.GKE_CLUSTER_NAME }}
location: ${{ steps.import_secrets.outputs.GKE_CLUSTER_ZONE }}
credentials: ${{ steps.import_secrets.outputs.GCP_SA }}
- name: Write values.yaml file
run: |
cat << EOF > values.yaml
environment: "staging"
api:
name: "api-staging"
image:
name: "ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}"
tag: "staging"
pullPolicy: "Always"
replicas: 1
resources:
limits:
cpu: 500m
memory: 1Gi
requests:
cpu: 250m
memory: 500Mi
envFrom:
- secretRef:
name: api-staging-secrets
settingsModule: "backend.settings.remote"
database:
host: "cloud-sql-proxy"
port: 5432
name: "api_staging"
user: "api_staging"
passwordSecret: "api-staging-database-password"
ingress:
enabled: true
host: "staging.backend.basedosdados.org"
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/rewrite-target: /
cert-manager.io/issuer: "letsencrypt-production"
nginx.ingress.kubernetes.io/ssl-redirect: "true"
tls:
- hosts:
- staging.backend.basedosdados.org
secretName: staging-api-basedosdados-org-tls
EOF
- name: Deploy using Helm
run: |-
helm upgrade \
--wait \
--install \
--namespace website \
--values values.yaml \
api-staging charts/basedosdados-api/.