Skip to content

Deploy to Development #65

Deploy to Development

Deploy to Development #65

Workflow file for this run

name: Deploy to Development
concurrency:
group: dev-${{ github.ref }}
cancel-in-progress: true
on:
workflow_dispatch:
inputs:
ttl:
description: "Deployment time to live in hours"
required: true
type: number
default: 24
jobs:
compute-sha:
name: Compute sha_short
runs-on: ubuntu-latest
outputs:
sha_short: ${{ steps.vars.outputs.sha_short }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Set vars
id: vars
run: |
echo "sha_short=$(git rev-parse --short ${{ github.sha }})" >> $GITHUB_OUTPUT
build-push:
name: Build and Push Images
needs: [compute-sha]
uses: ./.github/workflows/cd.yaml
with:
tag: ${{ needs.compute-sha.outputs.sha_short }}
secrets: inherit
deploy:
name: Deploy with SSH
needs: [compute-sha, build-push]
runs-on: ubuntu-latest
environment: development
steps:
- name: SSH and Helm Install
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.SSH_HOST }}
username: root
key: ${{ secrets.SSH_KEY }}
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 }} ./app --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 }}.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 \
--set nodeEnv=development
# Check container status
kubectl rollout status --timeout=1200s deployment bt-dev-app-${{ needs.compute-sha.outputs.sha_short }}-backend
kubectl rollout status --timeout=1200s deployment bt-dev-app-${{ needs.compute-sha.outputs.sha_short }}-frontend