Skip to content

Commit 4a27d4f

Browse files
committed
Add persistence
1 parent 78301b8 commit 4a27d4f

File tree

2 files changed

+102
-5
lines changed

2 files changed

+102
-5
lines changed

.github/workflows/deployment.yml

Lines changed: 101 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,16 @@ on:
1010
memory:
1111
description: 'Memory for the instance'
1212
type: string
13-
default: 512Mi
13+
default: 1Gi
1414
port:
1515
description: 'WebPort for the running instance'
1616
type: number
1717
default: 52773
18+
persistence:
19+
description: 'Set to true to persist your data.'
20+
required: false
21+
type: boolean
22+
default: false
1823
secrets:
1924
SERVICE_ACCOUNT_KEY:
2025
required: true
@@ -60,6 +65,7 @@ jobs:
6065
# if: github.event.repository.fork == false && github.event.repository.is_template == false
6166
name: Deploy to Cloud Run
6267
runs-on: ubuntu-22.04
68+
if: ${{ ! inputs.persistence }}
6369
steps:
6470
- name: Checkout
6571
uses: actions/checkout@v4
@@ -68,21 +74,21 @@ jobs:
6874
ref: ${{ inputs.ref }}
6975

7076
- name: Google Authentication
71-
uses: google-github-actions/[email protected].7
77+
uses: google-github-actions/[email protected].11
7278
with:
7379
credentials_json: ${{ secrets.SERVICE_ACCOUNT_KEY }}
7480

7581
- name: Get GKE credentials
76-
uses: google-github-actions/[email protected].0
82+
uses: google-github-actions/[email protected].4
7783
with:
7884
project_id: ${{ env.PROJECT_ID }}
7985
cluster_name: ${{ env.CLUSTER_NAME }}
8086
location: ${{ env.REGION }}
8187

8288
- name: Setup gcloud cli
83-
uses: google-github-actions/[email protected].2
89+
uses: google-github-actions/[email protected].5
8490
with:
85-
version: '504.0.0'
91+
version: '512.0.0'
8692

8793
- name: Authorize Docker push
8894
run: |
@@ -146,3 +152,93 @@ jobs:
146152
run: |
147153
kubectl version
148154
kubectl patch configmap config-domainmapping -n knative-serving -p '{"data":{"autoTLS":"Enabled"}}'
155+
156+
deploy-stateful-workload:
157+
name: Deploy Stateful Workload
158+
runs-on: ubuntu-22.04
159+
if: ${{ inputs.persistence }}
160+
steps:
161+
- name: Checkout
162+
uses: actions/checkout@v4
163+
with:
164+
repository: ${{ inputs.repository }}
165+
ref: ${{ inputs.ref }}
166+
167+
- name: Google Authentication
168+
uses: google-github-actions/[email protected]
169+
with:
170+
credentials_json: ${{ secrets.SERVICE_ACCOUNT_KEY }}
171+
172+
- name: Get GKE credentials
173+
uses: google-github-actions/[email protected]
174+
with:
175+
project_id: ${{ env.PROJECT_ID }}
176+
cluster_name: ${{ env.CLUSTER_NAME }}
177+
location: ${{ env.REGION }}
178+
179+
- name: Setup gcloud cli
180+
uses: google-github-actions/[email protected]
181+
with:
182+
version: '512.0.0'
183+
184+
- name: Authorize Docker push
185+
run: |
186+
gcloud --quiet auth configure-docker ${REGION}-docker.pkg.dev
187+
188+
- name: Build and Push image
189+
run: |
190+
docker buildx build -t ${REGION}-docker.pkg.dev/${PROJECT_ID}/community/${IMAGE_NAME}:${GITHUB_SHA} --push .
191+
192+
- name: Prepare Helm Environment Variables
193+
id: prepare_helm_vars
194+
run: |
195+
echo "[INFO] Escaping custom variables..."
196+
export CUSTOM_VARS_LIST_ESCAPED=$(echo "${{ secrets.CUSTOM_VARS_LIST }}" | sed -E 's/"/\\"/g')
197+
198+
if [[ -n "$CUSTOM_VARS_LIST_ESCAPED" ]]; then
199+
echo "[INFO] CUSTOM_VARS_LIST_ESCAPED contains data. Parsing key-values..."
200+
IFS=',' read -r -a ENV_PAIRS <<< "$CUSTOM_VARS_LIST_ESCAPED"
201+
202+
HELM_ARGS_ARRAY=()
203+
INDEX=1
204+
for PAIR in "${ENV_PAIRS[@]}"; do
205+
# Split each pair into KEY and VALUE at the first '='
206+
KEY="${PAIR%%=*}"
207+
VALUE="${PAIR#*=}"
208+
echo "[INFO] Setting key ${KEY}..."
209+
210+
HELM_ARGS_ARRAY+=(--set "extraEnv[$INDEX].name=$KEY,extraEnv[$INDEX].value=$VALUE")
211+
((INDEX++))
212+
done
213+
fi
214+
215+
# The HELM_ARGS_ARRAY is now ready to be used.
216+
# We can't pass arrays between steps, so we output the array
217+
# as a single, space-separated string for the next step to use.
218+
echo "helm_args=${HELM_ARGS_ARRAY[*]}" >> $GITHUB_OUTPUT
219+
220+
- name: Deploy Stateful Workload
221+
run: |
222+
echo "[INFO] Set google project..."
223+
gcloud config set project ${PROJECT_ID}
224+
225+
echo "[INFO] Escaping custom variables..."
226+
export CUSTOM_VARS_LIST_ESCAPED=$(echo "${{ secrets.CUSTOM_VARS_LIST }}" | sed -E 's/"/\\"/g')
227+
228+
echo "[INFO] Installing IRIS Helm charts repository..."
229+
helm repo add intersystems-charts https://charts.demo.community.intersystems.com
230+
231+
echo "[INFO] Deploy Helm release..."
232+
helm -n ${NAMESPACE} upgrade --install ${{ inputs.name }} intersystems-charts/iris-app \
233+
--version 0.0.1 \
234+
--set image.repository=${REGION}-docker.pkg.dev/${PROJECT_ID}/community/${IMAGE_NAME} \
235+
--set image.tag=${GITHUB_SHA} \
236+
--set resources.limits.memory=${SERVICE_MEMORY:-1Gi} \
237+
--set service.webPort=${SERVICE_PORT:-52773} \
238+
--set ingress.name=${{ inputs.name }} \
239+
--set ingress.domain=${DOMAIN_NAME} \
240+
--set extraEnv[0].name=ISC_DATA_DIRECTORY,extraEnv[0].value=/isc/data \
241+
${{ steps.prepare_helm_vars.outputs.helm_args }} \
242+
--wait \
243+
--atomic \
244+
--timeout 10m

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ jobs:
2424
## Optional
2525
# memory: 1Gi
2626
# port: 8081
27+
# persistence: true
2728
secrets:
2829
SERVICE_ACCOUNT_KEY: ${{ secrets.SERVICE_ACCOUNT_KEY }}
2930
## Optional

0 commit comments

Comments
 (0)