-
Notifications
You must be signed in to change notification settings - Fork 0
95 lines (76 loc) · 2.71 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
83
84
85
86
87
88
89
90
91
92
93
94
95
name: CI/CD Pipeline
on:
push:
branches:
- master
pull_request:
branches:
- master
env:
AWS_REGION: ${{ secrets.AWS_REGION }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
jobs:
build_and_push_frontend:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
# Caching builds
- name: Cache Docker layers for Frontend
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ hashFiles('klipbored-frontend/Dockerfile', 'klipbored-frontend/**') }}-${{ github.run_id }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Log in to Amazon ECR
uses: aws-actions/amazon-ecr-login@v1
with:
region: ${{ secrets.AWS_REGION }}
- name: Build and Push Frontend Docker Image
run: |
docker build -t ${{ secrets.FRONTEND_REPO }}:latest ./klipbored-frontend
docker push ${{ secrets.FRONTEND_REPO }}:latest
build_and_push_backend:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
# Caching builds
- name: Cache Docker layers for Backend
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ hashFiles('klipbored-backend/Dockerfile', 'klipbored-backend/**') }}-${{ github.run_id }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Log in to Amazon ECR
uses: aws-actions/amazon-ecr-login@v1
with:
region: ${{ secrets.AWS_REGION }}
- name: Build and Push Backend Docker Image
run: |
docker build -t ${{ secrets.BACKEND_REPO }}:latest ./klipbored-backend
docker push ${{ secrets.BACKEND_REPO }}:latest
deploy:
runs-on: ubuntu-latest
needs: [build_and_push_frontend, build_and_push_backend]
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Update Kubeconfig
run: |
aws eks update-kubeconfig --name ${{ secrets.EKS_CLUSTER_NAME }} --region ${{ secrets.AWS_REGION }}
- name: Deploy Frontend to EKS
run: |
kubectl apply -f ./k8s/frontend-deployment.yaml
kubectl rollout restart deployment/frontend-deployment
- name: Deploy Backend to EKS
run: |
kubectl apply -f ./k8s/backend-deployment.yaml
kubectl rollout restart deployment/backend-deployment