Skip to content

Commit

Permalink
refactor deploy step
Browse files Browse the repository at this point in the history
  • Loading branch information
maxmwang committed Nov 18, 2024
1 parent f98979e commit ff9ec1e
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 58 deletions.
36 changes: 14 additions & 22 deletions .github/workflows/cd-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,26 +44,18 @@ jobs:
uses: ./.github/workflows/deploy.yaml
with:
environment: development
script: |
set -e # Exit immediately if a command fails
cd ./infra
# Uninstall the old helm chart if it exists
helm uninstall bt-dev-app-${{ needs.compute-sha.outputs.sha_short }} || true
# Install new chart
helm install bt-dev-app-${{ needs.compute-sha.outputs.sha_short }} oci://registry-1.docker.io/octoberkeleytime/bt-app \
--version=0.1.0-dev.${{ needs.compute-sha.outputs.sha_short }} \
--namespace=bt \
--set env=dev \
--set ttl=${{ inputs.ttl }} \
--set-string frontend.image.tag=${{ needs.compute-sha.outputs.sha_short }} \
--set-string backend.image.tag=${{ needs.compute-sha.outputs.sha_short }} \
--set host=${{ needs.compute-sha.outputs.sha_short }}.dev.stanfurdtime.com \
--set mongoUri=mongodb://bt-dev-mongo-mongodb.bt.svc.cluster.local:27017/bt \
--set redisUri=redis://bt-dev-redis-master.bt.svc.cluster.local:6379 \
# Check container status
kubectl rollout status --timeout=180s deployment bt-dev-app-${{ needs.compute-sha.outputs.sha_short }}-backend
kubectl rollout status --timeout=180s deployment bt-dev-app-${{ needs.compute-sha.outputs.sha_short }}-frontend
name: bt-dev-app-${{ needs.compute-sha.outputs.sha_short }}
version: 0.1.0-dev.${{ needs.compute-sha.outputs.sha_short }}
values: |
env: dev
ttl: ${{ inputs.ttl }}
frontend:
image:
tag: ${{ needs.compute-sha.outputs.sha_short }}
backend:
image:
tag: ${{ needs.compute-sha.outputs.sha_short }}
host: ${{ needs.compute-sha.outputs.sha_short }}.dev.stanfurdtime.com
mongoUri: mongodb://bt-dev-mongo-mongodb.bt.svc.cluster.local:27017/bt
redisUri: redis://bt-dev-redis-master.bt.svc.cluster.local:6379
secrets: inherit
19 changes: 5 additions & 14 deletions .github/workflows/cd-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,8 @@ jobs:
uses: ./.github/workflows/deploy.yaml
with:
environment: production
script: |
set -e # Exit immediately if a command fails
cd ./infra
# Upgrade helm chart, or install if not exists
helm upgrade bt-prod-app oci://registry-1.docker.io/octoberkeleytime/bt-app \
--install \
--version="1.0.0" \
--namespace=bt \
--set host=stanfurdtime.com
# Check container status
kubectl rollout status --timeout=180s deployment bt-prod-app-backend
kubectl rollout status --timeout=180s deployment bt-prod-app-frontend
name: bt-prod-app
version: "1.0.0"
values: |
host: stanfurdtime.com
secrets: inherit
33 changes: 14 additions & 19 deletions .github/workflows/cd-stage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,17 @@ jobs:
uses: ./.github/workflows/deploy.yaml
with:
environment: staging
script: |
set -e # Exit immediately if a command fails
cd ./infra
# Upgrade helm chart, or install if not exists
helm upgrade bt-stage-app oci://registry-1.docker.io/octoberkeleytime/bt-app \
--install \
--version=0.1.0-stage \
--namespace=bt \
--set env=stage \
--set frontend.image.tag=latest \
--set backend.image.tag=latest \
--set host=staging.stanfurdtime.com \
--set mongoUri=mongodb://bt-stage-mongo-mongodb.bt.svc.cluster.local:27017/bt \
--set redisUri=redis://bt-stage-redis-master.bt.svc.cluster.local:6379
# Check container status
kubectl rollout status --timeout=180s deployment bt-stage-app-backend
kubectl rollout status --timeout=180s deployment bt-stage-app-frontend
name: bt-stage-app
version: 0.1.0-stage
values: |
env: stage
frontend:
image:
tag: latest
backend:
image:
tag: latest
host: staging.stanfurdtime.com
mongoUri: mongodb://bt-stage-mongo-mongodb.bt.svc.cluster.local:27017/bt
redisUri: redis://bt-stage-redis-master.bt.svc.cluster.local:6379
secrets: inherit
23 changes: 20 additions & 3 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,16 @@ on:
description: "Github action environment to deploy within"
required: true
type: string
script:
description: "Script to run on remote server"
name:
description: "Helm chart installation name"
required: true
type: string
version:
description: "Helm chart version"
required: true
type: string
values:
description: "Helm chart override values (yaml)"
required: true
type: string

Expand All @@ -28,4 +36,13 @@ jobs:
script: |
set -e # Exit immediately if a command fails
${{ inputs.script }}
# Upgrade helm chart, or install if not exists
helm upgrade ${{ inputs.name }} oci://registry-1.docker.io/octoberkeleytime/bt-app \
--install \
--version=${{ inputs.version }} \
--namespace=bt \
--values <(echo "${{ inputs.values }}")
# Check container status
kubectl rollout status --timeout=180s deployment ${{ inputs.name }}-backend
kubectl rollout status --timeout=180s deployment ${{ inputs.name }}-frontend

0 comments on commit ff9ec1e

Please sign in to comment.