forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
114 lines (98 loc) · 4.23 KB
/
Copy pathgcp_diarizer.yml
File metadata and controls
114 lines (98 loc) · 4.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
name: Deploy Diarizer to GKE
on:
# push:
# branches: [ "task/add-diarizer-with-pyannote-audio-model" ]
# paths:
# - 'backend/diarizer/**'
workflow_dispatch:
inputs:
environment:
description: 'Select the environment to deploy to'
required: true
default: 'development'
type: choice
options:
- development
- prod
branch:
description: 'Branch to deploy from'
required: true
default: 'main'
release_version:
description: 'Release version (optional)'
required: false
default: ''
# Serialize Helm writers to this environment's diarizer release.
concurrency:
group: deploy-gke-diarizer-${{ github.event.inputs.environment }}
cancel-in-progress: false
env:
SERVICE: diarizer
REGION: us-central1
jobs:
deploy:
environment: ${{ github.event.inputs.environment == 'prod' && 'prod' || 'development' }}
permissions:
contents: 'read'
id-token: 'write'
runs-on: ubuntu-latest
steps:
- name: Validate Environment Input
run: |
if [[ "${{ github.event.inputs.environment }}" != "development" && "${{ github.event.inputs.environment }}" != "prod" ]]; then
echo "Invalid environment: ${{ github.event.inputs.environment }}. Must be 'development' or 'prod'."
exit 1
fi
# To workaround "no space left on device" issue of GitHub-hosted runner
- name: Delete huge unnecessary tools folder
run: rm -rf /opt/hostedtoolcache
- name: Checkout
uses: actions/checkout@v7
- name: Google Auth
id: auth
uses: 'google-github-actions/auth@v3'
with:
credentials_json: ${{ secrets.GCP_CREDENTIALS }}
- name: Set up gcloud
uses: google-github-actions/setup-gcloud@v3
- run: gcloud auth configure-docker
- name: Build and Push Docker image
run: |
docker build -t gcr.io/${{ vars.GCP_PROJECT_ID }}/${{ env.SERVICE }}:${GITHUB_SHA::7} -f backend/${{ env.SERVICE }}/Dockerfile .
python3 backend/scripts/runtime_image_contracts.py smoke \
--dockerfile backend/diarizer/Dockerfile \
--image gcr.io/${{ vars.GCP_PROJECT_ID }}/${{ env.SERVICE }}:${GITHUB_SHA::7}
docker push gcr.io/${{ vars.GCP_PROJECT_ID }}/${{ env.SERVICE }}:${GITHUB_SHA::7}
- name: Get GKE credentials
uses: google-github-actions/get-gke-credentials@v3
with:
cluster_name: ${{ vars.GKE_CLUSTER }}
location: ${{ env.REGION }}
project_id: ${{ vars.GCP_PROJECT_ID }}
- name: Deploy Diarizer to GKE cluster using Helm
run: |
helm -n ${{ vars.ENV }}-omi-backend upgrade --install ${{ vars.ENV }}-omi-${{ env.SERVICE }} ./backend/charts/${{ env.SERVICE }} -f ./backend/charts/${{ env.SERVICE }}/${{ vars.ENV }}_omi_${{ env.SERVICE }}_values.yaml --set-string "image.tag=${GITHUB_SHA::7}"
- name: Verify rollout
run: |
if ! kubectl -n ${{ vars.ENV }}-omi-backend rollout status deploy/${{ vars.ENV }}-omi-${{ env.SERVICE }} --timeout=600s; then
python3 backend/scripts/deploy_status_report.py --env ${{ vars.ENV }} --include-gke --gke-service ${{ env.SERVICE }} || true
exit 1
fi
python3 backend/scripts/deploy_status_report.py --env ${{ vars.ENV }} --include-gke --gke-service ${{ env.SERVICE }}
- name: Generate deployment summary
if: always() && github.event.inputs.environment == 'prod'
uses: ./.github/actions/deployment-summary
with:
environment: ${{ github.event.inputs.environment }}
release_version: ${{ github.event.inputs.release_version }}
status: ${{ job.status }}
service: ${{ env.SERVICE }}
- name: Notify deployment status on Telegram
if: always() && github.event.inputs.environment == 'prod'
uses: ./.github/actions/deployment-notifier
with:
environment: ${{ github.event.inputs.environment }}
release_version: ${{ github.event.inputs.release_version }}
status: ${{ job.status }}
telegram_bot_token: ${{ secrets.TELEGRAM_BOT_TOKEN }}
telegram_chat_id: ${{ secrets.TELEGRAM_CHAT_ID }}