Skip to content

Commit

Permalink
feat: (ACC-664) simply deploy process for NMUI SaaS
Browse files Browse the repository at this point in the history
  • Loading branch information
pwilson77 committed Aug 8, 2024
1 parent 2222177 commit 9f700ac
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 165 deletions.
54 changes: 0 additions & 54 deletions .github/workflows/saas-deploy-dev.yml

This file was deleted.

56 changes: 0 additions & 56 deletions .github/workflows/saas-deploy-prod.yml

This file was deleted.

55 changes: 0 additions & 55 deletions .github/workflows/saas-deploy-staging.yml

This file was deleted.

95 changes: 95 additions & 0 deletions .github/workflows/saas-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: NMUI SaaS Deployment

on:
workflow_dispatch:
inputs:
version:
description: 'Version to deploy'
required: true
type: choice
options:
- 'v0.24.1'
- 'v0.24.2'
- 'v0.24.3'
- 'v0.25.0'
environment:
description: 'Environment to deploy to'
required: true
type: choice
options:
- 'dev'
- 'staging'
- 'prod'

jobs:
build-deploy:
runs-on: ubuntu-latest
steps:
- name: 'Checkout to release-${{ github.event.inputs.version }}'
uses: actions/checkout@v4
with:
ref: release-${{ github.event.inputs.version }}

- name: Set release tag
run: |
TAG="$(git rev-parse --short HEAD)"
echo "TAG=${TAG}" >> $GITHUB_ENV
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile.saas
platforms: linux/amd64
push: true
tags: ${{ github.repository_owner }}/netmaker-ui-saas:${{ env.TAG }}

- name: Set environment variables
run: |
if [ "${{ github.event.inputs.environment }}" == "dev" ]; then
echo "CLUSTER_NAME=saas-dev-cluster-europe-1" >> $GITHUB_ENV
elif [ "${{ github.event.inputs.environment }}" == "staging" ]; then
echo "CLUSTER_NAME=saas-staging-cluster-us-west" >> $GITHUB_ENV
elif [ "${{ github.event.inputs.environment }}" == "prod" ]; then
echo "CLUSTER_NAME=saas-prod-cluster-us-west" >> $GITHUB_ENV
fi
VERSION_WITH_DASHES=$(echo "${{ github.event.inputs.version }}" | tr '.' '-')
echo "VERSION_WITH_DASHES=${VERSION_WITH_DASHES}" >> $GITHUB_ENV
- name: Set up kubectl
uses: matootie/[email protected]
with:
personalAccessToken: ${{ secrets.DIGITALOCEAN_TOKEN }}
clusterName: ${{ env.CLUSTER_NAME }}

- name: Set k8s deployment image
run: kubectl set image deployment ${{ env.VERSION_WITH_DASHES }} netmaker-ui=${{ github.repository_owner }}/netmaker-ui-saas:${{ env.TAG }} -n accounts

- name: Set Intercom vars
run: |
if [ "${{ github.event.inputs.environment }}" == "dev" ]; then
kubectl set env deployment ${{ env.VERSION_WITH_DASHES }} PUBLIC_POSTHOG_HOST=${{ secrets.REACT_APP_PUBLIC_POSTHOG_DEV_KEY }} -n accounts
elif [ "${{ github.event.inputs.environment }}" == "staging" ]; then
kubectl set env deployment ${{ env.VERSION_WITH_DASHES }} PUBLIC_POSTHOG_HOST=${{ secrets.REACT_APP_PUBLIC_POSTHOG_DEV_KEY }} -n accounts
elif [ "${{ github.event.inputs.environment }}" == "prod" ]; then
kubectl set env deployment ${{ env.VERSION_WITH_DASHES }} PUBLIC_POSTHOG_HOST=${{ secrets.REACT_APP_PUBLIC_POSTHOG_KEY }} -n accounts
fi
kubectl set env deployment ${{ env.VERSION_WITH_DASHES }} INTERCOM_APP_ID=al371us8 -n accounts
kubectl set env deployment ${{ env.VERSION_WITH_DASHES }} PUBLIC_POSTHOG_KEY=${{ secrets.REACT_APP_PUBLIC_POSTHOG_HOST }} -n accounts
- name: Deploy to k8s cluster
run: kubectl rollout restart deploy ${{ env.VERSION_WITH_DASHES }} -n accounts

- name: Verify deployment
run: kubectl rollout status deployment/${{ env.VERSION_WITH_DASHES }} -n accounts

0 comments on commit 9f700ac

Please sign in to comment.