Skip to content

Commit bac8e2d

Browse files
committed
update workflow
1 parent 5b992cd commit bac8e2d

File tree

2 files changed

+250
-6
lines changed

2 files changed

+250
-6
lines changed
Lines changed: 244 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,244 @@
1+
name: Deployment 01F - Main - Argo CD Deploy and Promote
2+
3+
# on:
4+
# workflow_call:
5+
# secrets:
6+
# AWS_ACCESS_KEY_ID:
7+
# required: true
8+
# AWS_SECRET_ACCESS_KEY:
9+
# required: true
10+
# AWS_REGION:
11+
# required: true
12+
# AWS_ECR_LOGIN_URI:
13+
# required: true
14+
# ECR_REPOSITORY_NAME:
15+
# required: true
16+
# AWS_SECURITY_GROUP_ID:
17+
# required: true
18+
# AWS_SUBNET_ID_1:
19+
# required: true
20+
# PERSONAL_ACCESS_TOKEN:
21+
# required: true
22+
23+
# # When to run this workflow
24+
on:
25+
workflow_dispatch: # Manual trigger from GitHub UI
26+
# # Uncomment to enable automatic triggers
27+
# # push:
28+
# # branches: [ main ]
29+
# # pull_request:
30+
# # branches: [ main ]
31+
32+
# Environment variables used across jobs
33+
env:
34+
# ECR_REPOSITORY: ${{ secrets.ECR_REPOSITORY_NAME }}
35+
AWS_REGION: ${{ secrets.AWS_REGION }}
36+
# S3_BUCKET: ${{ secrets.S3_BUCKET_NAME }}
37+
# S3_DATA_PATH: data/ #data/files/md5
38+
39+
jobs:
40+
#----------------------------------------
41+
# JOB 1: Launch EC2 runner instance - CPU instance for setuping cluster environments
42+
#----------------------------------------
43+
launch-runner:
44+
name: 🚀 Launch EC2 Runner
45+
runs-on: ubuntu-latest
46+
outputs:
47+
label: ${{ steps.start-ec2-runner.outputs.label }}
48+
ec2-instance-id: ${{ steps.start-ec2-runner.outputs.ec2-instance-id }}
49+
commit_id: ${{ steps.get_commit_id_runner.outputs.commit_id }}
50+
51+
env:
52+
TF_LOG: DEBUG
53+
CML_VERBOSE: true
54+
55+
steps:
56+
- name: Checkout Code
57+
uses: actions/checkout@v4
58+
59+
- name: Configure AWS credentials
60+
uses: aws-actions/configure-aws-credentials@v4
61+
with:
62+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
63+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
64+
aws-region: ${{ secrets.AWS_REGION }}
65+
66+
- name: Display the commit ID
67+
run: |
68+
echo "Latest commit ID is: ${{ needs.build-and-push-ecr-image.outputs.commit_id }}"
69+
70+
- name: Get latest commit ID
71+
id: get_commit_id_runner
72+
run: |
73+
echo "commit_id=${{ needs.build-and-push-ecr-image.outputs.commit_id }}" >> $GITHUB_OUTPUT
74+
75+
- name: Start EC2 runner
76+
id: start-ec2-runner
77+
uses: machulav/ec2-github-runner@v2.3.9
78+
with:
79+
mode: start
80+
github-token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
81+
# AMI with CUDA/GPU drivers
82+
# ec2-image-id: ami-01654480b8a1994bd
83+
# ec2-instance-type: g4dn.xlarge
84+
85+
# AMI with CPU only
86+
# ec2-image-id: ami-0e35ddab05955cf57
87+
ec2-image-id: ami-01654480b8a1994bd
88+
ec2-instance-type: t3a.xlarge
89+
subnet-id: ${{ secrets.AWS_SUBNET_ID_1 }}
90+
security-group-id: ${{ secrets.AWS_SECURITY_GROUP_ID }}
91+
market-type: "spot"
92+
93+
#----------------------------------------
94+
# JOB 2: Train model and deploy
95+
#----------------------------------------
96+
do-the-job:
97+
name: Cluster Setup - Argo CD Deployment - Prompte Model
98+
needs: [launch-runner]
99+
runs-on: ${{ needs.launch-runner.outputs.label }}
100+
outputs:
101+
commit_id: ${{ steps.get_commit_id_ec2.outputs.commit_id }}
102+
timeout-minutes: 60
103+
104+
steps:
105+
- name: Checkout Code
106+
uses: actions/checkout@v4
107+
108+
- name: Configure AWS credentials
109+
uses: aws-actions/configure-aws-credentials@v4
110+
with:
111+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
112+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
113+
aws-region: ${{ secrets.AWS_REGION }}
114+
115+
- name: Setup installations
116+
env:
117+
REPO_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
118+
CML_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
119+
run: |
120+
pwd
121+
122+
# Assumed git actions checks out the repo and gets inside it
123+
cd K8SDeploy/eks-cluster-config
124+
125+
pwd
126+
127+
# EKSCTL
128+
curl -sLO "https://github.com/eksctl-io/eksctl/releases/latest/download/eksctl_Linux_amd64.tar.gz"
129+
130+
tar -xzf eksctl_Linux_amd64.tar.gz -C /tmp && rm eksctl_Linux_amd64.tar.gz
131+
sudo mv /tmp/eksctl /usr/local/bin
132+
133+
# AWS-EKS
134+
curl -O https://s3.us-west-2.amazonaws.com/amazon-eks/1.32.0/2024-12-20/bin/linux/amd64/kubectl
135+
chmod +x ./kubectl
136+
mkdir -p $HOME/bin && cp ./kubectl $HOME/bin/kubectl && export PATH=$HOME/bin:$PATH
137+
138+
# Docker
139+
curl -fsSL https://get.docker.com -o get-docker.sh
140+
sudo sh get-docker.sh
141+
142+
# AWS
143+
# curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
144+
# unzip awscliv2.zip
145+
# sudo ./aws/install
146+
147+
# Helm
148+
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
149+
chmod 700 get_helm.sh
150+
./get_helm.sh
151+
152+
# ArgoCD
153+
curl -sSL -o argocd-linux-amd64 https://github.com/argoproj/argo-cd/releases/latest/download/argocd-linux-amd64
154+
sudo install -m 555 argocd-linux-amd64 /usr/local/bin/argocd
155+
# rm argocd-linux-amd64
156+
157+
# node for cml comment
158+
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
159+
sudo apt-get install -y nodejs
160+
npm install -g @dvcorg/cml
161+
162+
- name: Get path
163+
run: |
164+
pwd
165+
166+
# 2. Checkout Repo ArgoCD (separate folder)
167+
# https://github.com/ajithvcoder/emlo4-session-18-ajithvcoder-canary-argocd-kserve.git
168+
- name: Checkout Repo ArgoCD
169+
uses: actions/checkout@v4
170+
with:
171+
repository: ajithvcoder/emlo4-session-18-ajithvcoder-canary-argocd-kserve
172+
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} # PAT with write access to Repo B
173+
path: emlo4-session-18-ajithvcoder-canary-argocd-kserve
174+
175+
- name: Model 1 - Run test and promote if >90% success
176+
working-directory: emlo4-session-18-ajithvcoder-canary-argocd-kserve
177+
continue-on-error: true
178+
run: |
179+
180+
pwd
181+
182+
ls -la
183+
184+
echo "Hi this is a test comment 1" >> report.md
185+
186+
cml comment create report.md
187+
188+
- name: Model 2 - Run test and promote if >90% success
189+
working-directory: emlo4-session-18-ajithvcoder-canary-argocd-kserve
190+
continue-on-error: true
191+
run: |
192+
echo "Hi this is a test comment 2" >> report.md
193+
194+
cml comment create report.md
195+
196+
cp report.md ../
197+
198+
- name: CML Comment
199+
env:
200+
REPO_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
201+
CML_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
202+
run: |
203+
pwd
204+
205+
ls -la
206+
207+
cml comment create report.md
208+
209+
210+
- name: Delete Entire Stack
211+
continue-on-error: true
212+
run: |
213+
# get inside the dir
214+
cd K8SDeploy/eks-cluster-config || true
215+
216+
# delete cluster
217+
eksctl delete cluster -f eks-cluster.yaml --disable-nodegroup-eviction
218+
219+
#----------------------------------------
220+
# JOB 3: Stop EC2 runner after completion
221+
#----------------------------------------
222+
stop-runner:
223+
name: Stop self-hosted EC2 runner
224+
needs:
225+
- launch-runner
226+
- do-the-job
227+
runs-on: ubuntu-latest
228+
if: ${{ always() }}
229+
steps:
230+
- name: Configure AWS credentials
231+
uses: aws-actions/configure-aws-credentials@v4
232+
with:
233+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
234+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
235+
aws-region: ${{ secrets.AWS_REGION }}
236+
237+
- name: Stop EC2 runner
238+
uses: machulav/ec2-github-runner@v2.3.9
239+
with:
240+
mode: stop
241+
github-token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
242+
label: ${{ needs.launch-runner.outputs.label }}
243+
ec2-instance-id: ${{ needs.launch-runner.outputs.ec2-instance-id }}
244+

.github/workflows/01_Deployment_Main.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ name: Deployment 01 - Main Trigger Workflow
44
# pull_request:
55
# types: [opened, synchronize, reopened]
66

7-
# on:
8-
# workflow_dispatch:
9-
107
on:
11-
push:
12-
branches:
13-
- dev_1
8+
workflow_dispatch:
9+
10+
# on:
11+
# push:
12+
# branches:
13+
# - dev_1
1414

1515
jobs:
1616
# trigger-train:

0 commit comments

Comments
 (0)