-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (71 loc) · 2.08 KB
/
ci_cd.yml
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
name: CI/CD
on:
push:
branch: ['main']
pull_request:
jobs:
check:
name: continuous integration checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: 18
- name: cargo cache
uses: actions/cache@v3
with:
path: target
key: ${{ hashFiles('Cargo.lock') }}-dev
- name: npm cache
uses: actions/cache@v3
with:
path: node_modules
key: ${{ hashFiles('pnpm-lock.yaml') }}
- name: make check
run: make check
push_container:
name: build and push Docker container
if: ${{ github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
environment: Kubernetes
steps:
- uses: actions/checkout@v4
- name: cargo cache
uses: actions/cache@v3
with:
path: target
key: ${{ hashFiles('Cargo.lock') }}-prod
- name: npm cache
uses: actions/cache@v3
with:
path: node_modules
key: ${{ hashFiles('pnpm-lock.yaml') }}
- name: login to docker hub
uses: docker/login-action@v3
with:
username: jdevries3133
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: setup-musl
run: sudo apt-get install -y musl-tools
- name: push the container to Docker Hub
run: make push-container
deploy:
name: deploy to Kubernetes with Terraform
if: ${{ github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
needs: [check, push_container]
environment: Kubernetes
steps:
- uses: actions/checkout@v4
- name: setup kubectl
run: |
mkdir ~/.kube
echo "${{ secrets.KUBE_CONFIG }}" > ~/.kube/config
- name: perform deployment
env:
# credentials are used for terraform state bucket
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
TF_VAR_openai_api_key: ${{ secrets.OPENAI_API_KEY }}
run: make deploy