-
Notifications
You must be signed in to change notification settings - Fork 51
104 lines (88 loc) · 3.41 KB
/
build-docker.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
96
97
98
99
100
101
102
103
104
name: Deploy to k8s
on:
push:
branches:
- main
- beta
- develop
env:
DO_CLUSTER: ${{ secrets.DO_CLUSTER }}
DOCKER_LOGIN: ${{ secrets.DOCKER_LOGIN }}
DOCKER_PWD: ${{ secrets.DOCKER_PWD }}
jobs:
build:
name: Build server
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build application Docker image
run: |
docker build --cache-from=illa-builder-backend -f illa-builder-backend.dockerfile -t illa-builder-backend .
- name: Push application Docker image
run: |
docker login -u $DOCKER_LOGIN -p $DOCKER_PWD
docker tag illa-builder-backend "illasoft/illa-builder-backend:${GITHUB_REF_NAME}"
docker push "illasoft/illa-builder-backend:${GITHUB_REF_NAME}"
build-ws:
name: Build ws server
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build application Docker image
run: |
docker build --cache-from=illa-builder-backend-ws -f illa-builder-backend-websocket.dockerfile -t illa-builder-backend-ws .
- name: Push application Docker image
run: |
docker login -u $DOCKER_LOGIN -p $DOCKER_PWD
docker tag illa-builder-backend-ws "illasoft/illa-builder-backend-ws:${GITHUB_REF_NAME}"
docker push "illasoft/illa-builder-backend-ws:${GITHUB_REF_NAME}"
build-internal:
name: Build internal server
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build application Docker image
run: |
docker build --cache-from=illa-builder-backend-internal -f illa-builder-backend-internal.dockerfile -t illa-builder-backend-internal .
- name: Push application Docker image
run: |
docker login -u $DOCKER_LOGIN -p $DOCKER_PWD
docker tag illa-builder-backend-internal "illasoft/illa-builder-backend-internal:${GITHUB_REF_NAME}"
docker push "illasoft/illa-builder-backend-internal:${GITHUB_REF_NAME}"
deploy:
name: 'Deploy'
needs: [build, build-ws, build-internal]
runs-on: ubuntu-latest
environment:
name:
${{ (github.ref == 'refs/heads/main') && 'production' || (github.ref ==
'refs/heads/develop') && 'test' || (github.ref == 'refs/heads/beta') &&
'beta' }}
env:
ILLA_APP_ENV: ${{ vars.ILLA_APP_ENV }}
steps:
- name: Install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DO_TOKEN }}
- name: Install kubectl
run: |
sudo snap install kubectl --classic
- name: Setup kubectl
run: |
doctl kubernetes cluster kubeconfig save $DO_CLUSTER
kubectl version
- uses: actions/checkout@v4
with:
repository: illacloud/k8s-application-do
token: ${{ secrets.ILLA_BOT_TOKEN }}
path: k8s-application-do
- name: Deploy to Kubernetes
run: |
cd k8s-application-do/namespace-$ILLA_APP_ENV
kubectl delete pod -n $ILLA_APP_ENV -l repo=illa-builder-backend
kubectl delete pod -n $ILLA_APP_ENV -l repo=illa-builder-backend-ws
kubectl delete pod -n $ILLA_APP_ENV -l repo=illa-builder-backend-internal
kubectl apply -f ./illa-builder-backend/ -n $ILLA_APP_ENV
kubectl apply -f ./illa-builder-backend-ws/ -n $ILLA_APP_ENV
kubectl apply -f ./illa-builder-backend-internal/ -n $ILLA_APP_ENV