This repository has been archived by the owner on Mar 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
206 lines (183 loc) · 7.87 KB
/
maven.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
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
name: Java CI with Maven
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
name: Build
runs-on: ${{ matrix.os }}
strategy:
matrix:
java-version: [ 17 ]
os: [ "ubuntu-latest" ]
steps:
# 检出代码
- name: Checkout repository
uses: actions/checkout@v3
# 设置JDK版本
- name: Set up JDK ${{ matrix.java-version }}
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java-version }}
distribution: 'temurin'
- name: Cache modules
uses: actions/cache@v3
id: cache-modules
with:
path: |
~/.m2/repository
~/.npm
$GITHUB_WORKSPACE/passport-ui/node/
$GITHUB_WORKSPACE/passport-ui/node_modules/
$GITHUB_WORKSPACE/ui/node/
$GITHUB_WORKSPACE/ui/node_modules/
key: ${{ matrix.os }}-${{ hashFiles('pom.xml', '**/pom.xml', '**/**/pom.xml', '**/package.json') }}
restore-keys: |
${{ matrix.os }}-
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: CI ENV
id: date
# bash, sh, cmd, powershell, pwsh
# shell 类型必须为 sh,否则:
# $GITHUB_ENV:仅支持 ubuntu、macos
# $env:GITHUB_ENV:仅支持 windows
shell: sh
run: |
env
echo $GITHUB_RUN_ID
echo $GITHUB_JOB-${{ matrix.java-version }}
echo "CI_PIPELINE_ID=$GITHUB_RUN_ID" >> $GITHUB_ENV
echo "CI_JOB_ID=$GITHUB_JOB-${{ matrix.java-version }}" >> $GITHUB_ENV
- name: Build with Maven
run: |
mvn clean -e -U package source:jar javadoc:jar install -DskipTests
sed -i 's@registry\.jihulab\.com/xuxiaowei-cloud/xuxiaowei-cloud-next/alibabadragonwell/[email protected]/alibabadragonwell/dragonwell@g' ./**/Dockerfile ./**/**/Dockerfile
sed -i 's@registry\.jihulab\.com/xuxiaowei-cloud/xuxiaowei-cloud-next/[email protected]/library/nginx@g' ./**/Dockerfile
mvn -pl admin-server docker:build -Ddocker.host=unix:///var/run/docker.sock
mvn -pl gateway docker:build -Ddocker.host=unix:///var/run/docker.sock
mvn -pl passport docker:build -Ddocker.host=unix:///var/run/docker.sock
mvn -pl resource-services-parent/canal docker:build -Ddocker.host=unix:///var/run/docker.sock
mvn -pl resource-services-parent/file docker:build -Ddocker.host=unix:///var/run/docker.sock
mvn -pl resource-services-parent/master-data docker:build -Ddocker.host=unix:///var/run/docker.sock
mvn -pl resource-services-parent/user docker:build -Ddocker.host=unix:///var/run/docker.sock
mvn -pl resource-services-parent/webservice docker:build -Ddocker.host=unix:///var/run/docker.sock
mvn -pl resource-services-parent/websocket docker:build -Ddocker.host=unix:///var/run/docker.sock
mvn -pl resource-services-parent/wechat-miniprogram docker:build -Ddocker.host=unix:///var/run/docker.sock
mvn -pl resource-services-parent/wechat-offiaccount docker:build -Ddocker.host=unix:///var/run/docker.sock
mvn -pl ui docker:build -Ddocker.host=unix:///var/run/docker.sock
mvn -pl xxl-job-admin docker:build -Ddocker.host=unix:///var/run/docker.sock
docker images
rm -rf /home/runner/.m2/repository/cloud/xuxiaowei
rm -rf /home/runner/.m2/repository/cn/com/xuxiaowei
# https://docs.github.com/zh/enterprise-cloud@latest/code-security/dependabot/working-with-dependabot/automating-dependabot-with-github-actions
dependabot:
name: Dependabot
# 需要所有 build 完成后,才运行
needs: build
runs-on: ${{ matrix.os }}
permissions:
# 可以修改仓库中的文件内容
contents: write
# # 可以新建或修改 Pull Request
pull-requests: write
# 依赖机器人 && 仅PR
if: ${{ github.actor == 'dependabot[bot]' && github.event_name == 'pull_request' }}
strategy:
matrix:
os: [ "ubuntu-latest" ]
steps:
# 检出代码
- name: Checkout repository
uses: actions/checkout@v3
with:
# 获取所有的代码历史记录,包括分支和标签
fetch-depth: 0
- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v1
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
- name: echo
run: |
echo ${{ github.event.pull_request.html_url }}
echo ${{ steps.metadata.outputs.dependency-names }}
echo ${{ steps.metadata.outputs.update-type }}
echo ${{ 'version-update:semver-patch' }}
- name: Enable auto-merge for Dependabot PRs
# if: ${{contains(steps.metadata.outputs.dependency-names, 'my-dependency') && steps.metadata.outputs.update-type == 'version-update:semver-patch'}}
run: gh pr merge --auto --merge "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# 将 main 分支代码同步到 极狐GitLab
- name: Sync JihuLab
run: |
git config --global user.email "[email protected]"
git config --global user.name "徐晓伟"
# 设置 SSH 秘钥
mkdir -p ~/.ssh
echo "${{ secrets.JIHULAB_ID_RSA }}" >> ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
eval $(ssh-agent -s) && ssh-add ~/.ssh/id_rsa
# 信任域名
ssh-keyscan -H jihulab.com >> ~/.ssh/known_hosts
# 切换 main 分支
git checkout main
# 拉取 main 分支
git pull origin main
# 查看远端 极狐GitLab
echo [email protected]:$GITHUB_REPOSITORY.git
# 添加远端 极狐GitLab
git remote add jihulab [email protected]:$GITHUB_REPOSITORY.git
# 拉取 main 分支
git pull --progress -v --no-rebase jihulab main
# 推送 main 分支
git push --progress jihulab main:main
sync:
name: Sync
# 需要所有 build 完成后,才运行
needs: build
# 仅在推送代码时执行
if: github.event_name == 'push'
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ "ubuntu-latest" ]
steps:
# 检出代码
- name: Checkout repository
uses: actions/checkout@v3
with:
# 获取所有的代码历史记录,包括分支和标签
fetch-depth: 0
# 将代码同步到 极狐GitLab
- name: Sync JihuLab
run: |
git config --global user.email "[email protected]"
git config --global user.name "徐晓伟"
# 设置 SSH 秘钥
mkdir -p ~/.ssh
echo "${{ secrets.JIHULAB_ID_RSA }}" >> ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
eval $(ssh-agent -s) && ssh-add ~/.ssh/id_rsa
# 信任域名
ssh-keyscan -H jihulab.com >> ~/.ssh/known_hosts
# 查看当前分支
echo 当前分支:$GITHUB_REF_NAME
# 查看远端 极狐GitLab
echo [email protected]:$GITHUB_REPOSITORY.git
# 添加远端 极狐GitLab
git remote add jihulab [email protected]:$GITHUB_REPOSITORY.git
# 拉取
git pull --progress -v --no-rebase jihulab $GITHUB_REF_NAME
# 推送当前分支
git push --progress jihulab $GITHUB_REF_NAME:$GITHUB_REF_NAME