Merge remote-tracking branch 'refs/remotes/origin/gql' into gql #42
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy to Staging | |
concurrency: stage | |
on: | |
push: | |
branches: [master, gql] | |
jobs: | |
build-push: | |
name: Build and Push Images | |
uses: ./.github/workflows/cd.yaml | |
with: | |
tag: latest | |
secrets: inherit | |
deploy: | |
name: Deploy with SSH | |
needs: [build-push] | |
runs-on: ubuntu-latest | |
environment: staging | |
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-stage-app ; then | |
# Restart deployments if the Helm release exists | |
kubectl rollout restart deployment bt-stage-app-backend | |
kubectl rollout restart deployment bt-stage-app-frontend | |
else | |
# Install the Helm release if it doesn't exist | |
helm install bt-stage-app ./app --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 | |
fi | |
# Check container status | |
kubectl rollout status --timeout=180s deployment bt-stage-app-backend | |
kubectl rollout status --timeout=180s deployment bt-stage-app-frontend |