Skip to content

Deploy to Production #8

Deploy to Production

Deploy to Production #8

Workflow file for this run

name: Deploy to Production
concurrency: prod
on:
workflow_dispatch:
jobs:
branch-check:
name: Environment Check
runs-on: ubuntu-latest
environment: production
steps:
- name: Pass
run: echo "Passed check"
build-push:
name: Build and Push Images
needs: [branch-check]
uses: ./.github/workflows/cd.yaml
with:
tag: prod
secrets: inherit
deploy:
name: Deploy with SSH
needs: [build-push]
runs-on: ubuntu-latest
steps:
- name: SSH and Helm Install
uses: appleboy/[email protected]
with:
host: ${{ secrets.SSH_HOST }}
username: root
key: ${{ secrets.SSH_KEY }}
script: |
set -e # Exit immediately if a command fails
cd ./infra
# Check if the Helm release exists
if helm status bt-prod-app ; then
# Restart deployments if the Helm release exists
kubectl rollout restart deployment bt-prod-app-backend
kubectl rollout restart deployment bt-prod-app-frontend
else
# Install the Helm release if it doesn't exist
helm install bt-prod-app ./app --namespace=bt \
--set host=stanfurdtime.com
fi
# Check container status
kubectl rollout status --timeout=180s deployment bt-prod-app-backend
kubectl rollout status --timeout=180s deployment bt-prod-app-frontend