-
Notifications
You must be signed in to change notification settings - Fork 0
131 lines (108 loc) · 3.32 KB
/
blank.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
name: Build
on:
push:
branches: [master]
pull_request:
jobs:
api-build:
name: Build backend 🏗️
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./api
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: "zulu"
java-version: 17
- name: Cache Gradle packages
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }}
- name: Build backend
run: ./gradlew bootJar
- name: Tar build
run: tar -czf ~/backend.tgz ./build
- uses: actions/upload-artifact@v3
if: always()
with:
name: backend
path: |
~/backend.tgz
backend-test:
name: Test backend 🧪
needs: [api-build]
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./api
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: "zulu"
java-version: 17
- name: Cache Gradle packages
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }}
- name: Test backend
run: ./gradlew test
backend-docker:
name: Backend docker 🐬
needs: [backend-test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: benjlevesque/[email protected]
id: short-sha
- name: Download backend build result
uses: actions/download-artifact@v2
with:
name: backend
path: ~/
- name: Untar it
run: |
tar -xzf ~/backend.tgz ./build
- name: cp build
run: |
sudo cp -R ./build ./api/build
- name: list
run: |
sudo tree -a
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_TOKEN }}
- name: Build Docker image
run: docker build ./api --tag ${{ secrets.REGISTRY_USERNAME }}/graph-api:${{ steps.short-sha.outputs.sha }} --build-arg=GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD) --build-arg=GIT_COMMIT=${SHORT_SHA}
- name: Push Docker image
run: docker push ${{ secrets.REGISTRY_USERNAME }}/graph-api:${{ steps.short-sha.outputs.sha }}
deployment:
name: Deployment 🚀
runs-on: ubuntu-latest
needs: [backend-docker]
steps:
- uses: actions/checkout@v3
- uses: imranismail/setup-kustomize@v2
- name: Creat application-live.properties file
run: |
echo "${{ secrets.SPRING_BOOT_APPLICATION_PROPERTIES }}" > deployment/templates/application.properties
- name: Build kustomize deployment config
run: ./deployment/deployment.sh
- name: apply deloyment
uses: actions-hub/[email protected]
env:
KUBE_CONFIG: ${{ secrets.K8S_CONFIG }}
with:
args: apply -f deployment/prod.yml