Skip to content

Commit

Permalink
managed-dashboard ci initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mabdulmoghni committed Dec 2, 2023
1 parent 27c1889 commit 29bd7da
Show file tree
Hide file tree
Showing 4 changed files with 219 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pr-cloud-dashboard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
pull_request:
branches:
- main
- managed-dashboard
- staging

jobs:

Expand Down Expand Up @@ -41,7 +41,7 @@ jobs:
uses: docker/metadata-action@v3
with:
images: |
docker.io/kotalco/cloud-dashboard
docker.io/kotalco/cloud-dashboard-pr
tags: |
type=ref,event=tag
type=sha,prefix=,suffix=,format=short
Expand Down
100 changes: 93 additions & 7 deletions .github/workflows/publish-cloud-dashboard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ name: Build-Push dashboard

on:
push:
branches: [ main ]
branches:
- main
- staging
tags:
- 'v*'

Expand Down Expand Up @@ -53,12 +55,28 @@ jobs:
# path: cypress/videos
# if-no-files-found: ignore # 'warn' or 'error' are also available, defaults to `warn`

- name: Generate Docker metadata
id: meta


- name: Generate Docker metadata for staging
id: meta-staging
uses: docker/metadata-action@v3
if: github.ref == 'refs/heads/staging'
with:
images: |
docker.io/kotalco/cloud-dashboard
docker.io/kotalco/cloud-dashboard-staging
tags: |
type=ref,event=tag
type=sha,prefix=,suffix=,format=short
flavor: |
latest=true
- name: Generate Docker metadata for production
id: meta-production
uses: docker/metadata-action@v3
if: github.ref == 'refs/heads/main'
with:
images: |
docker.io/kotalco/cloud-dashboard-production
tags: |
type=ref,event=tag
type=sha,prefix=,suffix=,format=short
Expand All @@ -76,11 +94,79 @@ jobs:
with:
username: kotalco
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Build and push staging
uses: docker/build-push-action@v3
if: github.ref == 'refs/heads/staging'
with:
context: .
push: true
tags: ${{ steps.meta-staging.outputs.tags }}
labels: ${{ steps.meta-staging.outputs.labels }}

- name: Build and push
- name: Build and push production
uses: docker/build-push-action@v3
if: github.ref == 'refs/heads/main'
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
tags: ${{ steps.meta-production.outputs.tags }}
labels: ${{ steps.meta-production.outputs.labels }}

deploy_managed-dashboard_k8s-managed-staging:
runs-on: ubuntu-latest
needs: [build]
if: ${{ (github.event_name == 'push') && (github.ref == 'refs/heads/staging') }}
steps:
- uses: actions/checkout@v3

- name: Add SHORT_SHA env property with commit short sha
run: echo "SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-7`" >> $GITHUB_ENV

- name: update managed-dashboard with secrets values - staging
env:
NEXT_PUBLIC_BASE_URL: '${{ secrets.NEXT_PUBLIC_BASE_URL }}'
run: |
envsubst < ./staging-managed-dashboard.yaml | tee staging-managed-dashboard.yaml
- name: K8s-set-context to DO managed-staging cluster
uses: azure/k8s-set-context@v1
with:
method: kubeconfig
kubeconfig: ${{ secrets.KUBECONFIG_DO_MANAGED_STAGING }}

- name: Deploy to the DO managed-staging cluster
uses: azure/k8s-deploy@v1
with:
namespace: kotal
manifests: |
staging-managed-dashboard.yaml
# deploy_managed-dashboard_k8s-managed-production:
# runs-on: ubuntu-latest
# needs: [build]
# if: ${{ (github.event_name == 'push') && (github.ref == 'refs/heads/main') }}
# steps:
# - uses: actions/checkout@v3

# - name: Add SHORT_SHA env property with commit short sha
# run: echo "SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-7`" >> $GITHUB_ENV

# - name: update managed-dashboard with secrets values - production
# env:
# NEXT_PUBLIC_BASE_URL: '${{ secrets.NEXT_PUBLIC_BASE_URL }}'
# run: |
# envsubst < ./prod-managed-dashboard.yaml | tee prod-managed-dashboard.yaml

# - name: K8s-set-context to DO managed-production cluster
# uses: azure/k8s-set-context@v1
# with:
# method: kubeconfig
# kubeconfig: ${{ secrets.KUBECONFIG_DO_MANAGED_PRODUCTION }}

# - name: Deploy to the DO managed-production cluster
# uses: azure/k8s-deploy@v1
# with:
# namespace: kotal
# manifests: |
# prod-managed-dashboard.yaml
62 changes: 62 additions & 0 deletions prod-managed-dashboard.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
deployment.kubernetes.io/revision: "1"
generation: 1
labels:
app.kubernetes.io/managed-by: Helm
name: kotal-dashboard
namespace: kotal
spec:
progressDeadlineSeconds: 600
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
app: kotal-dashboard
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
creationTimestamp: null
labels:
app: kotal-dashboard
spec:
containers:
- env:
- name: NEXT_PUBLIC_BASE_URL
value: /api/v1
- name: NEXT_PUBLIC_WS_BASE_URL
value: /api/v1
image: kotalco/cloud-dashboard-production:${SHORT_SHA}
imagePullPolicy: IfNotPresent
name: kotal-dashboard
ports:
- containerPort: 3000
protocol: TCP
resources:
requests:
cpu: 10m
memory: 50Mi
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30
---
apiVersion: v1
kind: Service
metadata:
name: kotal-dashboard
spec:
selector:
app: kotal-dashboard
ports:
- port: 3000
targetPort: 3000
62 changes: 62 additions & 0 deletions staging-managed-dashboard.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
deployment.kubernetes.io/revision: "1"
generation: 1
labels:
app.kubernetes.io/managed-by: Helm
name: kotal-dashboard
namespace: kotal
spec:
progressDeadlineSeconds: 600
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
app: kotal-dashboard
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
creationTimestamp: null
labels:
app: kotal-dashboard
spec:
containers:
- env:
- name: NEXT_PUBLIC_BASE_URL
value: /api/v1
- name: NEXT_PUBLIC_WS_BASE_URL
value: /api/v1
image: kotalco/cloud-dashboard-staging:${SHORT_SHA}
imagePullPolicy: IfNotPresent
name: kotal-dashboard
ports:
- containerPort: 3000
protocol: TCP
resources:
requests:
cpu: 10m
memory: 50Mi
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30
---
apiVersion: v1
kind: Service
metadata:
name: kotal-dashboard
spec:
selector:
app: kotal-dashboard
ports:
- port: 3000
targetPort: 3000

0 comments on commit 29bd7da

Please sign in to comment.