forked from elizaOS/eliza
-
Notifications
You must be signed in to change notification settings - Fork 0
109 lines (98 loc) · 3.55 KB
/
deploy-staging.yaml
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
name: Build & Deploy [STAGING]
on:
push:
branches:
- main
paths:
- 'characters/**'
- 'client/**'
- 'agent/**'
- 'packages/**'
- 'package.json'
- 'turbo.json'
- 'Dockerfile'
- '.github/workflows/deploy-staging.yaml'
- 'helm/**'
jobs:
build-and-push:
name: Build & Push
runs-on: ubuntu-latest
environment: qa
env:
REGISTRY_ENDPOINT: ${{ secrets.REGISTRY_ENDPOINT }}
REGISTRY_REPOSITORY: ${{ secrets.REGISTRY_REPOSITORY }}
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
outputs:
short_sha: ${{ steps.sha.outputs.short_sha }}
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set GitHub commit short SHA
id: sha
run: |
CALCULATED_SHA=$(git rev-parse --short ${{ github.sha }})
echo "short_sha=$CALCULATED_SHA" >> $GITHUB_OUTPUT
- name: Login to private registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY_ENDPOINT }}
username: ${{ env.REGISTRY_USERNAME }}
password: ${{ env.REGISTRY_PASSWORD }}
logout: true
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Docker image(s)
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: |
${{ env.REGISTRY_ENDPOINT }}/${{ env.REGISTRY_REPOSITORY }}/eliza:latest
${{ env.REGISTRY_ENDPOINT }}/${{ env.REGISTRY_REPOSITORY }}/eliza:${{ steps.sha.outputs.short_sha }}
cache-from: type=gha,scope=${{ github.ref }}-eliza
cache-to: type=gha,mode=max,scope=${{ github.ref }}-eliza
deploy:
name: Deploy to k8s
runs-on: ubuntu-latest
environment: qa
env:
REGISTRY_ENDPOINT: ${{ secrets.REGISTRY_ENDPOINT }}
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
KUBECONFIG_FILE: ${{ secrets.KUBECONFIG }}
HELM_RELEASE_NAMESPACE: ${{ vars.HELM_RELEASE_NAMESPACE }}
HELM_RELEASE_NAME: ${{ vars.HELM_RELEASE_NAME }}
HELM_CHART_REPOSITORY: ${{ secrets.HELM_CHART_REPOSITORY }}
HELM_CHART_VERSION: ${{ vars.HELM_CHART_VERSION }}
needs: build-and-push
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Login to private registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY_ENDPOINT }}
username: ${{ env.REGISTRY_USERNAME }}
password: ${{ env.REGISTRY_PASSWORD }}
logout: true
- name: Configure Kubernetes config file
run: |
mkdir -p $HOME/.kube/
echo "${{ env.KUBECONFIG_FILE }}" | base64 -d > $HOME/.kube/config
- name: Upgrade installed Helm chart release
run: |
helm upgrade \
--install \
--debug \
--atomic \
--wait \
--values helm/values/qa.yaml \
--set agent.image.tag=${{ needs.build-and-push.outputs.short_sha }} \
--set client.image.tag=${{ needs.build-and-push.outputs.short_sha }} \
-n ${{ env.HELM_RELEASE_NAMESPACE }} \
${{ env.HELM_RELEASE_NAME }} \
${{ env.HELM_CHART_REPOSITORY }} \
--version ${{ env.HELM_CHART_VERSION }}