Spaces:
Sleeping
Sleeping
Zhichao
commited on
Commit
•
cc1a55e
1
Parent(s):
eae2367
Github action for deploying to prod (#78)
Browse files
.github/workflows/prod-deploy.yml
ADDED
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: deploy to aws production
|
2 |
+
|
3 |
+
on: workflow_dispatch
|
4 |
+
|
5 |
+
env:
|
6 |
+
repo_name: "vision-agent"
|
7 |
+
aws_account_id: "944932498359"
|
8 |
+
aws_region: "us-east-2"
|
9 |
+
cluster_name: "llens-app-production"
|
10 |
+
namespace: "datamanagement"
|
11 |
+
|
12 |
+
jobs:
|
13 |
+
db_migration:
|
14 |
+
runs-on: ubuntu-latest
|
15 |
+
environment: aws-production
|
16 |
+
|
17 |
+
permissions:
|
18 |
+
id-token: write
|
19 |
+
contents: read
|
20 |
+
|
21 |
+
steps:
|
22 |
+
- uses: actions/checkout@v4
|
23 |
+
with:
|
24 |
+
ref: main
|
25 |
+
|
26 |
+
- name: Set up Node.js
|
27 |
+
uses: actions/setup-node@v4
|
28 |
+
with:
|
29 |
+
node-version: "20"
|
30 |
+
|
31 |
+
- name: Install pnpm
|
32 |
+
run: npm install -g [email protected]
|
33 |
+
|
34 |
+
- name: Install dependencies
|
35 |
+
run: pnpm install
|
36 |
+
|
37 |
+
- name: prisma migrate deploy
|
38 |
+
env:
|
39 |
+
POSTGRES_PRISMA_URL: ${{ vars.DB_MIGRATION_URL }}
|
40 |
+
POSTGRES_URL_NON_POOLING: ${{ vars.DB_MIGRATION_URL }}
|
41 |
+
run: |
|
42 |
+
mkdir -p ~/.ssh
|
43 |
+
echo "${{ secrets.BASTION_SSH_KEY }}" > ~/.ssh/id_ed25519
|
44 |
+
chmod 600 ~/.ssh/id_ed25519
|
45 |
+
ssh-keyscan -H 3.142.222.176 >> ~/.ssh/known_hosts
|
46 |
+
ssh -o StrictHostKeyChecking=no -fN -v -L localhost:5432:platform.db.app.landing.ai:5432 [email protected]
|
47 |
+
pnpm prisma migrate deploy
|
48 |
+
|
49 |
+
deploy_to_aws_production:
|
50 |
+
needs: db_migration
|
51 |
+
|
52 |
+
runs-on: ubuntu-latest
|
53 |
+
environment: aws-production
|
54 |
+
|
55 |
+
permissions:
|
56 |
+
id-token: write
|
57 |
+
contents: read
|
58 |
+
|
59 |
+
steps:
|
60 |
+
- uses: actions/checkout@v4
|
61 |
+
with:
|
62 |
+
ref: main
|
63 |
+
|
64 |
+
- name: Configure AWS Credentials
|
65 |
+
uses: aws-actions/configure-aws-credentials@v4
|
66 |
+
with:
|
67 |
+
role-to-assume: arn:aws:iam::${{ env.aws_account_id }}:role/github-actions-role
|
68 |
+
aws-region: ${{ env.aws_region }}
|
69 |
+
|
70 |
+
- name: kubeconfig
|
71 |
+
run: |
|
72 |
+
aws sts get-caller-identity
|
73 |
+
aws eks update-kubeconfig --name ${{ env.cluster_name }} --region ${{ env.aws_region }}
|
74 |
+
|
75 |
+
- name: install helm
|
76 |
+
run: |
|
77 |
+
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
|
78 |
+
|
79 |
+
- name: get image tag based on the sha
|
80 |
+
id: sha_short
|
81 |
+
run: |
|
82 |
+
echo "image_tag=$(git rev-parse --short HEAD)"
|
83 |
+
echo "image_tag=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
|
84 |
+
|
85 |
+
- name: helm upgrade --install
|
86 |
+
env:
|
87 |
+
IMAGE_TAG: ${{ steps.sha_short.outputs.image_tag }}
|
88 |
+
run: |
|
89 |
+
helm upgrade --install -n ${{ env.namespace }} ${{ env.repo_name }} -f chart/${{ vars.VALUES_FILE }} ./chart \
|
90 |
+
--set image.tag=$IMAGE_TAG \
|
91 |
+
--set env.AWS_BUCKET_NAME=${{ vars.AWS_BUCKET_NAME }} \
|
92 |
+
--set env.AWS_REGION=${{ vars.AWS_REGION }} \
|
93 |
+
--set env.NEXTAUTH_URL=${{ vars.NEXTAUTH_URL }} \
|
94 |
+
--set env.AUTH_GITHUB_ID=${{ vars.AUTH_GITHUB_ID }} \
|
95 |
+
--set env.AUTH_GITHUB_SECRET=${{ vars.AUTH_GITHUB_SECRET }} \
|
96 |
+
--set env.AUTH_SECRET=${{ vars.AUTH_SECRET }} \
|
97 |
+
--set env.AUTH_TRUST_HOST=${{ vars.AUTH_TRUST_HOST }} \
|
98 |
+
--set env.AWS_ACCESS_KEY_ID=${{ vars.AWS_ACCESS_KEY_ID }} \
|
99 |
+
--set env.AWS_SECRET_ACCESS_KEY=${{ vars.AWS_SECRET_ACCESS_KEY }} \
|
100 |
+
--set env.GOOGLE_CLIENT_ID=${{ vars.GOOGLE_CLIENT_ID }} \
|
101 |
+
--set env.GOOGLE_SECRET=${{ vars.GOOGLE_SECRET }} \
|
102 |
+
--set env.LOKI_AUTH_USER_PASSWORD=${{ vars.LOKI_AUTH_USER_PASSWORD }} \
|
103 |
+
--set env.OPENAI_API_KEY=${{ vars.OPENAI_API_KEY }} \
|
104 |
+
--set env.POSTGRES_PRISMA_URL=${{ vars.POSTGRES_PRISMA_URL }}
|