Skip to content

Commit 54ba784

Browse files
committed
deployment
1 parent 85d9f5f commit 54ba784

File tree

2 files changed

+138
-11
lines changed

2 files changed

+138
-11
lines changed

.github/workflows/deployment.yml

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
name: Cloud Run Deploy
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
name:
7+
description: 'Domain name of deployment, before `.demo.community.intersystems.com`'
8+
required: true
9+
type: string
10+
secrets:
11+
SERVICE_ACCOUNT_KEY:
12+
required: true
13+
workflow_dispatch:
14+
inputs:
15+
repository:
16+
description: 'Deploying repository'
17+
required: true
18+
type: string
19+
ref:
20+
description: 'Branch Name in deploying repository'
21+
required: true
22+
type: choice
23+
default: main
24+
options:
25+
- master
26+
- main
27+
name:
28+
description: 'Domain name of deployment, before `.demo.community.intersystems.com`'
29+
required: true
30+
type: string
31+
32+
env:
33+
# Change this section according to your needs
34+
IMAGE_NAME: ${{ inputs.name }}
35+
SERVICE: ${{ inputs.name }}
36+
DOMAIN_NAME: ${{ inputs.name }}.demo.community.intersystems.com
37+
38+
# Leave this section untouched
39+
PROJECT_ID: iris-community-demos
40+
CLUSTER_NAME: demo
41+
GITHUB_SHA: ${{ github.sha }}
42+
GCR_LOCATION: eu.gcr.io
43+
REGION: europe-west2
44+
NAMESPACE: demo
45+
46+
jobs:
47+
deploy-cloud-run:
48+
if: github.event.repository.fork == false && github.event.repository.is_template == false
49+
name: Deploy to Cloud Run
50+
runs-on: ubuntu-20.04
51+
steps:
52+
- name: Checkout
53+
uses: actions/checkout@v2
54+
with:
55+
repository: ${{ inputs.repository }}
56+
ref: ${{ inputs.ref }}
57+
58+
- name: 'Cloud Auth'
59+
uses: 'google-github-actions/auth@v0'
60+
with:
61+
credentials_json: '${{ secrets.SERVICE_ACCOUNT_KEY }}'
62+
63+
- name: Setup Cloud SDK
64+
uses: google-github-actions/[email protected]
65+
66+
- name: Authorize Docker push
67+
run: |
68+
gcloud auth list
69+
gcloud auth configure-docker
70+
71+
- name: Build and Push image
72+
run: |
73+
docker buildx build -t ${GCR_LOCATION}/${PROJECT_ID}/${IMAGE_NAME}:${GITHUB_SHA} --push .
74+
75+
- name: Deploy to Cloud Run
76+
run: |
77+
echo "[INFO] Set google project..."
78+
gcloud config set project ${PROJECT_ID}
79+
80+
echo "[INFO] Deploy service..."
81+
gcloud run deploy ${SERVICE} \
82+
--platform gke \
83+
--cluster ${CLUSTER_NAME} \
84+
--cluster-location ${REGION} \
85+
--namespace ${NAMESPACE} \
86+
--port 52773 \
87+
--min-instances 1 \
88+
--memory 512Mi \
89+
--timeout 300 \
90+
--verbosity debug \
91+
--image ${GCR_LOCATION}/${PROJECT_ID}/${IMAGE_NAME}:${GITHUB_SHA}
92+
93+
echo "[INFO] Create domain mappings..."
94+
if [[ $(gcloud run domain-mappings list --platform gke --cluster ${CLUSTER_NAME} --cluster-location ${REGION} --namespace ${NAMESPACE} --filter "DOMAIN=${DOMAIN_NAME}" | grep -v DOMAIN | wc -l) == 0 ]]; then
95+
gcloud run domain-mappings create \
96+
--service ${SERVICE} \
97+
--platform gke \
98+
--cluster ${CLUSTER_NAME} \
99+
--cluster-location ${REGION} \
100+
--namespace ${NAMESPACE} \
101+
--verbosity debug \
102+
--domain ${DOMAIN_NAME}
103+
fi
104+
105+
- name: Create domain name
106+
run: |
107+
gcloud container clusters get-credentials ${CLUSTER_NAME} --region ${REGION} --project ${PROJECT_ID}
108+
kubectl version
109+
echo "[INFO] Checking if [${DOMAIN_NAME}] is in the existing Ingress annotation..."
110+
CURRENT_DOMAINS_LIST=$(kubectl -n gke-system get svc istio-ingress -o jsonpath="{.metadata.annotations['external-dns\.alpha\.kubernetes\.io/hostname']}")
111+
if [[ $(echo ${CURRENT_DOMAINS_LIST} | grep -w "${DOMAIN_NAME}" | wc -c) -eq 0 ]]; then \
112+
echo "[INFO] Domain [${DOMAIN_NAME}] is ABSENT in the domains list. Adding..."; \
113+
kubectl -n gke-system annotate --overwrite svc istio-ingress external-dns\.alpha\.kubernetes\.io/hostname=${CURRENT_DOMAINS_LIST},${DOMAIN_NAME}; \
114+
echo -n "[INFO] Resulting domain names: "
115+
kubectl -n gke-system get svc istio-ingress -o jsonpath="{.metadata.annotations['external-dns\.alpha\.kubernetes\.io/hostname']}"
116+
else
117+
echo "[INFO] Domain [${DOMAIN_NAME}] is in the domains list. Leave untouched..."; \
118+
fi
119+
120+
- name: Enable TLS-access
121+
run: |
122+
gcloud container clusters get-credentials ${CLUSTER_NAME} --region ${REGION} --project ${PROJECT_ID}
123+
kubectl version
124+
kubectl patch configmap config-domainmapping -n knative-serving -p '{"data":{"autoTLS":"Enabled"}}'

README.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
1-
InterSystems Demo Deployment action
1+
InterSystems Demo Deployment
22
===
33

4-
54
Usage
65
==
76

7+
In your repository create file `.github/workflows/deploy.yml` with content. Replace `<name-of-demo>` with the domain name, which will be used before `.demo.community.intersystems.com`. Ask for deployment key and set it to secrets as `SERVICE_ACCOUNT_KEY`
8+
89
```yaml
10+
name: Cloud Run Deploy
11+
912
on:
1013
push:
1114
branches:
12-
- master
13-
- main
15+
- master
16+
- main
17+
workflow_dispatch:
18+
1419
jobs:
1520
deploy:
16-
runs-on: ubuntu-latest
17-
steps:
18-
- name: Deploy Demo
19-
if: github.event.repository.fork == false && github.event.repository.is_template == false
20-
uses: intersystems-community/demo-deployment@master
21-
with:
22-
name: demo
21+
uses: intersystems-community/demo-deployment/.github/workflows/deployment.yml@master
22+
with:
23+
name: <name-of-demo>
24+
secrets:
25+
SERVICE_ACCOUNT_KEY: ${{ secrets.SERVICE_ACCOUNT_KEY }}
2326
```

0 commit comments

Comments
 (0)