-
Notifications
You must be signed in to change notification settings - Fork 73
309 lines (282 loc) · 14.7 KB
/
microservice-docker-image.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
# 构建docker image
#### https://github.com/marketplace?type=actions
#### https://github.com/sdras/awesome-actions
name: Microservice Docker Image
on:
push:
paths:
- 'taotao-cloud-microservice/**'
branches: [ master ]
pull_request:
branches: [ master ]
env:
TAOTAO_CLOUD_OSSRH_USERNAME: ${{ secrets.TAOTAO_CLOUD_OSSRH_USERNAME }}
TAOTAO_CLOUD_OSSRH_PASSWORD: ${{ secrets.TAOTAO_CLOUD_OSSRH_PASSWORD }}
TAOTAO_CLOUD_MAVEN_USERNAME: ${{ secrets.TAOTAO_CLOUD_MAVEN_USERNAME }}
TAOTAO_CLOUD_MAVEN_USERNAME_NEW: ${{ secrets.TAOTAO_CLOUD_MAVEN_USERNAME_NEW }}
TAOTAO_CLOUD_MAVEN_PASSWORD: ${{ secrets.TAOTAO_CLOUD_MAVEN_PASSWORD }}
TAOTAO_CLOUD_MAVEN_PASSWORD_NEW: ${{ secrets.TAOTAO_CLOUD_MAVEN_PASSWORD_NEW }}
TAOTAO_CLOUD_GITHUB_USERNAME: ${{ secrets.TAOTAO_CLOUD_GITHUB_USERNAME }}
TAOTAO_CLOUD_GITHUB_TOKEN: ${{ secrets.TAOTAO_CLOUD_GITHUB_TOKEN }}
TAOTAO_CLOUD_REGISTRY_USERNAME: ${{ secrets.TAOTAO_CLOUD_REGISTRY_USERNAME }}
TAOTAO_CLOUD_REGISTRY_PASSWORD: ${{ secrets.TAOTAO_CLOUD_REGISTRY_PASSWORD }}
TAOTAO_CLOUD_VERSION: 2024.09
jobs:
build:
runs-on: ubuntu-latest
if: ${{ contains(github.event.head_commit.message, 'taotao-cloud-docker-image') }}
steps:
#https://github.com/marketplace/actions/checkout
- name: Checkout Project
uses: actions/checkout@v4.1.7
#- name: Set up JDK 21
# uses: actions/setup-java@v4.2.1
# with:
# java-version: 21
# distribution: 'temurin'
#https://github.com/marketplace/actions/github-action-for-graalvm
- uses: graalvm/setup-graalvm@v1
with:
java-version: '21'
distribution: 'graalvm'
github-token: ${{ secrets.TAOTAO_CLOUD_GITHUB_TOKEN }}
native-image-job-reports: 'true'
- name: Example step
run: |
echo "GRAALVM_HOME: $GRAALVM_HOME"
echo "JAVA_HOME: $JAVA_HOME"
java --version
native-image --version
#https://github.com/marketplace/actions/cache
- name: Cache Gradle Packages
uses: actions/cache@v4
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Show Github
run: echo "$GITHUB_CONTEXT"
env:
GITHUB_CONTEXT: ${{ toJSON(github) }}
MESSAGE_IS_TRUE: ${{ contains(github.event.head_commit.message, 'taotao-cloud-monitor') }}
MESSAGES: ${{ github.event.head_commit.message }}
# base64 secring.gpg > secring.gpg.b64 SIGNING_SECRET_KEY_RING_FILE -> secring.gpg.b64
- name: Decode Signing Secret Key Ring File
run: |
echo "${{ secrets.TAOTAO_CLOUD_SIGNING_SECRET_KEY_RING_FILE }}" > ~/secring.gpg.b64 && base64 -d ~/secring.gpg.b64 > ~/secring.gpg
echo "signing.keyId=${{ secrets.TAOTAO_CLOUD_SIGNING_KEY_ID }}" >> gradle.properties
echo "signing.password=${{ secrets.TAOTAO_CLOUD_SIGNING_PASSWORD }}" >> gradle.properties
echo "signing.secretKeyRingFile=$HOME/secring.gpg" >> gradle.properties
- name: write secrets maven username password
run: |
echo "mavenUsernameNew=${{ secrets.TAOTAO_CLOUD_MAVEN_USERNAME_NEW }}" >> gradle.properties
echo "mavenPasswordNew=${{ secrets.TAOTAO_CLOUD_MAVEN_PASSWORD_NEW }}" >> gradle.properties
#- name: echo gradle
# run: |
# gradle -v
# which gradle
# env
# cat gradle.properties
# echo ${{ secrets.TAOTAO_CLOUD_MAVEN_PASSWORD_NEW }} | base64
#- name: Build And Publish Dependencies To Local
# run: |
# cd ${{ github.workspace }}/taotao-cloud-dependencies
# gradle publishToMavenLocal
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
with:
gradle-version: 8.10
#https://github.com/marketplace/actions/gradle-build-action
- name: Gradle BootJar taotao-cloud-monitor
if: ${{ contains(github.event.head_commit.message, 'taotao-cloud-monitor') }}
run: gradle -p taotao-cloud-microservice/taotao-cloud-monitor clean bootJar -x test -Pprofile=dev
#https://github.com/marketplace/actions/publish-docker
- name: Publish Docker Image taotao-cloud-monitor
if: ${{ contains(github.event.head_commit.message, 'taotao-cloud-monitor') }}
uses: elgohr/Publish-Docker-Github-Action@v5
env:
DINGDING_TOKEN_ID_ARG: ${{ secrets.DING_TOKEN }}
DINGDING_SECRET_ARG: ${{ secrets.DING_SECRET }}
with:
name: registry.cn-hangzhou.aliyuncs.com/taotao-cloud-project/taotao-cloud-monitor
username: ${{ secrets.TAOTAO_CLOUD_REGISTRY_USERNAME }}
password: ${{ secrets.TAOTAO_CLOUD_REGISTRY_PASSWORD }}
registry: registry.cn-hangzhou.aliyuncs.com
buildoptions: "--compress --force-rm"
buildargs: DINGDING_SECRET_ARG,DINGDING_TOKEN_ID_ARG
tags: "${{env.TAOTAO_CLOUD_VERSION}}"
workdir: ${{ github.workspace }}/taotao-cloud-microservice/taotao-cloud-monitor
#https://github.com/marketplace/actions/ssh-remote-commands
- name: Ssh To server To execute taotao-cloud-monitor script
#uses: fifsky/ssh-action@master
uses: appleboy/ssh-action@v1.0.3
with:
#command: |
# cd /develop/work/education-back-server
# sh start.sh
host: ${{secrets.SERVER_HOST}}
username: ${{secrets.SERVER_USERNAME}}
port: ${{secrets.SERVER_PORT }}
#key: ${{secrets.SERVER_PRIVATE_KEY}}
password: ${{secrets.SERVER_PASSWORD}}
script:
sh /develop/work/taotao-cloud/taotao-cloud-monitor-start.sh
# sh start.sh
- name: Gradle BootJar taotao-cloud-gateway
if: ${{ contains(github.event.head_commit.message, 'taotao-cloud-gateway') }}
run: gradle -p taotao-cloud-microservice/taotao-cloud-gateway clean bootJar -x test -Pprofile=dev
- name: Publish Docker Image taotao-cloud-gateway
uses: elgohr/Publish-Docker-Github-Action@v5
if: ${{ contains(github.event.head_commit.message, 'taotao-cloud-gateway') }}
with:
name: registry.cn-hangzhou.aliyuncs.com/taotao-cloud-project/taotao-cloud-gateway
username: ${{ secrets.TAOTAO_CLOUD_REGISTRY_USERNAME }}
password: ${{ secrets.TAOTAO_CLOUD_REGISTRY_PASSWORD }}
registry: registry.cn-hangzhou.aliyuncs.com
buildoptions: "--compress --force-rm"
tags: "${{env.TAOTAO_CLOUD_VERSION}}"
workdir: ${{ github.workspace }}/taotao-cloud-microservice/taotao-cloud-gateway
- name: Gradle BootJar taotao-cloud-auth
if: ${{ contains(github.event.head_commit.message, 'taotao-cloud-auth') }}
run: gradle -p taotao-cloud-microservice/taotao-cloud-business/taotao-cloud-auth/taotao-cloud-auth-biz clean bootJar -x test -Pprofile=dev
- name: Publish Docker Image taotao-cloud-auth
uses: elgohr/Publish-Docker-Github-Action@v5
if: ${{ contains(github.event.head_commit.message, 'taotao-cloud-auth') }}
with:
name: registry.cn-hangzhou.aliyuncs.com/taotao-cloud-project/taotao-cloud-auth
username: ${{ secrets.TAOTAO_CLOUD_REGISTRY_USERNAME }}
password: ${{ secrets.TAOTAO_CLOUD_REGISTRY_PASSWORD }}
registry: registry.cn-hangzhou.aliyuncs.com
buildoptions: "--compress --force-rm"
tags: "${{env.TAOTAO_CLOUD_VERSION}}"
workdir: ${{ github.workspace }}/taotao-cloud-microservice/taotao-cloud-business/taotao-cloud-auth/taotao-cloud-auth-biz
- name: Gradle BootJar taotao-cloud-xxljob
if: ${{ contains(github.event.head_commit.message, 'taotao-cloud-xxljob') }}
run: gradle -p taotao-cloud-microservice/taotao-cloud-xxljob clean bootJar -x test -Pprofile=dev
- name: Publish Docker Image taotao-cloud-xxljob
uses: elgohr/Publish-Docker-Github-Action@v5
if: ${{ contains(github.event.head_commit.message, 'taotao-cloud-xxljob') }}
with:
name: registry.cn-hangzhou.aliyuncs.com/taotao-cloud-project/taotao-cloud-xxljob
username: ${{ secrets.TAOTAO_CLOUD_REGISTRY_USERNAME }}
password: ${{ secrets.TAOTAO_CLOUD_REGISTRY_PASSWORD }}
registry: registry.cn-hangzhou.aliyuncs.com
buildoptions: "--compress --force-rm"
tags: "${{env.TAOTAO_CLOUD_VERSION}}"
workdir: ${{ github.workspace }}/taotao-cloud-microservice/taotao-cloud-xxljob
- name: Gradle BootJar taotao-cloud-order
if: ${{ contains(github.event.head_commit.message, 'taotao-cloud-order') }}
run: gradle -p taotao-cloud-microservice/taotao-cloud-business/taotao-cloud-order/taotao-cloud-order-biz clean bootJar -x test -Pprofile=dev
- name: Publish Docker Image taotao-cloud-order
uses: elgohr/Publish-Docker-Github-Action@v5
if: ${{ contains(github.event.head_commit.message, 'taotao-cloud-order') }}
with:
name: registry.cn-hangzhou.aliyuncs.com/taotao-cloud-project/taotao-cloud-order
username: ${{ secrets.TAOTAO_CLOUD_REGISTRY_USERNAME }}
password: ${{ secrets.TAOTAO_CLOUD_REGISTRY_PASSWORD }}
registry: registry.cn-hangzhou.aliyuncs.com
buildoptions: "--compress --force-rm"
tags: "${{env.TAOTAO_CLOUD_VERSION}}"
workdir: ${{ github.workspace }}/taotao-cloud-microservice/taotao-cloud-business/taotao-cloud-order/taotao-cloud-order-biz
- name: Gradle BootJar taotao-cloud-sys
if: ${{ contains(github.event.head_commit.message, 'taotao-cloud-sys') }}
run: gradle -p taotao-cloud-microservice/taotao-cloud-business/taotao-cloud-sys/taotao-cloud-sys-biz clean bootJar -x test -Pprofile=dev
- name: Publish Docker Image taotao-cloud-sys
uses: elgohr/Publish-Docker-Github-Action@v5
if: ${{ contains(github.event.head_commit.message, 'taotao-cloud-sys') }}
with:
name: registry.cn-hangzhou.aliyuncs.com/taotao-cloud-project/taotao-cloud-sys
username: ${{ secrets.TAOTAO_CLOUD_REGISTRY_USERNAME }}
password: ${{ secrets.TAOTAO_CLOUD_REGISTRY_PASSWORD }}
registry: registry.cn-hangzhou.aliyuncs.com
buildoptions: "--compress --force-rm"
tags: "${{env.TAOTAO_CLOUD_VERSION}}"
workdir: ${{ github.workspace }}/taotao-cloud-microservice/taotao-cloud-business/taotao-cloud-sys/taotao-cloud-sys-biz
- name: Gradle BootJar taotao-cloud-job
if: ${{ contains(github.event.head_commit.message, 'taotao-cloud-job') }}
run: gradle -p taotao-cloud-microservice/taotao-cloud-business/taotao-cloud-job/taotao-cloud-job-biz clean bootJar -x test -Pprofile=dev
- name: Publish Docker Image taotao-cloud-job
uses: elgohr/Publish-Docker-Github-Action@v5
if: ${{ contains(github.event.head_commit.message, 'taotao-cloud-job') }}
with:
name: registry.cn-hangzhou.aliyuncs.com/taotao-cloud-project/taotao-cloud-job
username: ${{ secrets.TAOTAO_CLOUD_REGISTRY_USERNAME }}
password: ${{ secrets.TAOTAO_CLOUD_REGISTRY_PASSWORD }}
registry: registry.cn-hangzhou.aliyuncs.com
buildoptions: "--compress --force-rm"
tags: "${{env.TAOTAO_CLOUD_VERSION}}"
workdir: ${{ github.workspace }}/taotao-cloud-microservice/taotao-cloud-business/taotao-cloud-job/taotao-cloud-job-biz
- name: Gradle BootJar taotao-cloud-file
if: ${{ contains(github.event.head_commit.message, 'taotao-cloud-file') }}
run: gradle -p taotao-cloud-microservice/taotao-cloud-business/taotao-cloud-file/taotao-cloud-file-biz clean bootJar -x test -Pprofile=dev
- name: Publish Docker Image taotao-cloud-file
uses: elgohr/Publish-Docker-Github-Action@v5
if: ${{ contains(github.event.head_commit.message, 'taotao-cloud-file') }}
with:
name: registry.cn-hangzhou.aliyuncs.com/taotao-cloud-project/taotao-cloud-file
username: ${{ secrets.TAOTAO_CLOUD_REGISTRY_USERNAME }}
password: ${{ secrets.TAOTAO_CLOUD_REGISTRY_PASSWORD }}
registry: registry.cn-hangzhou.aliyuncs.com
buildoptions: "--compress --force-rm"
tags: "${{env.TAOTAO_CLOUD_VERSION}}"
workdir: ${{ github.workspace }}/taotao-cloud-microservice/taotao-cloud-business/taotao-cloud-file/taotao-cloud-file-biz
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4.5.0
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
#- name: login to registry
# uses: docker/login-action@v1
# with:
# registry: registry.cn-hangzhou.aliyuncs.com
# username: ${{ secrets.TAOTAO_CLOUD_REGISTRY_USERNAME }}
# password: ${{ secrets.TAOTAO_CLOUD_REGISTRY_PASSWORD }}
#https://github.com/marketplace/actions/dingding-notify-action
- name: build success
if: ${{ success() }}
uses: zcong1993/actions-ding@master
with:
dingToken: ${{ secrets.DING_TOKEN }}
secret: ${{ secrets.DING_SECRET }}
# body 内容 https://blog.csdn.net/lxw1844912514/article/details/125747327
body: |
{
"msgtype": "text",
"text": {
"content": "taotao github action [taotao-cloud-microservice-docker-image] publish docker image success"
}
}
- name: build failure
if: ${{ failure() }}
uses: zcong1993/actions-ding@master
with:
dingToken: ${{ secrets.DING_TOKEN }}
secret: ${{ secrets.DING_SECRET }}
# body 内容 https://blog.csdn.net/lxw1844912514/article/details/125747327
body: |
{
"msgtype": "text",
"text": {
"content": "taotao github action [taotao-cloud-microservice-docker-image] publish docker image failure"
}
}
# - name: build success
# if: ${{ success() }}
# uses: fifsky/dingtalk-action@master
# with:
# url: https://oapi.dingtalk.com/robot/send?access_token=${{ secrets.TAOTAO_CLOUD_DINGTAOK_TOKEN }}
# type: markdown
# content: |
# # 💯👨💻 Success 🎉🎉🎉
# > [Microservice Starters Publish Aliyun] Publish Docker success
# > ^_^ from github action message
#
# - name: build error
# if: ${{ error() }}
# uses: fifsky/dingtalk-action@master
# with:
# url: https://oapi.dingtalk.com/robot/send?access_token=${{ secrets.TAOTAO_CLOUD_DINGTAOK_TOKEN }}
# type: markdown
# content: |
# # 💯👨💻 Error 🎉🎉🎉
# > [Microservice Starters Publish Aliyun] Publish Docker error
# > ^_^ from github action message