-
Notifications
You must be signed in to change notification settings - Fork 196
182 lines (165 loc) · 6.39 KB
/
code-check.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
# This workflow will build a Java project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
name: Build Agent and Upload To OSS
on:
push:
branches:
- main
- beta
- develop
pull_request:
branches:
- main
- beta
- develop
paths-ignore:
- '.github/**'
- 'changes/**'
- 'deploy/**'
- '**.md'
- '**.yml'
- '**.xml'
- 'LICENSE'
- '.gitignore'
schedule:
- cron: '0 10 * * *'
jobs:
Cache-Dependencies:
name: Cache dependencies
if: github.repository == 'HXSecurity/DongTai-agent-java'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Set up Maven
uses: stCarolas/setup-maven@v4
with:
maven-version: 3.2.5
- uses: actions/cache@v2
id: mvn-cache # use this to check for `cache-hit` (`steps.mvn-cache.outputs.cache-hit != 'true'`)
with:
path: ~/.m2 # !WARN does not work if running multiple node versions, instead use https://github.com/actions/cache/blob/master/examples.md#node---yarn
key: ${{ runner.os }}-mvn-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-mvn-
- name: Mvn Install
if: steps.mvn-cache.outputs.cache-hit != 'true'
run: mvn -B compile -Dmaven.test.skip=true
Build-Agent:
name: Build Java Agent
if: github.event_name == 'pull_request' || github.event_name == 'schedule'
runs-on: ubuntu-latest
needs: [ Cache-Dependencies ]
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Set up Maven
uses: stCarolas/setup-maven@v4
with:
maven-version: 3.2.5
- name: Restore dependencies from cache
uses: actions/cache@v2
with:
path: ~/.m2
key: ${{ runner.os }}-mvn-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-mvn-
- name: Build DongTai-Java-Agent With Maven
run: |
mvn -version
mvn -B package -Dmaven.test.skip=true
- uses: shogo82148/actions-setup-mysql@v1
with:
mysql-version: '8.0'
auto-start: true
root-password: yuhjnbGYUI
user: test
password: test
# - name: OpenRASP-Vulns-Test
# run: bash .github/workflows/scripts/openrasp-test.sh "OpenRASP" "${{ github.event_name }}-${{ github.run_number }}"
#
# - name: Benchmark-Vulns-Test
# run: bash .github/workflows/scripts/benchmark-test.sh "OWASP-Benchmark" "${{ github.event_name }}-${{ github.run_number }}"
Upload-To-OSS:
name: Upload To TEST OSS
if: github.event_name == 'push'
runs-on: ubuntu-latest
needs: [ Cache-Dependencies ]
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Set up Maven
uses: stCarolas/setup-maven@v4
with:
maven-version: 3.2.5
- name: Get the release version
id: version
run: echo ::set-output name=GITHUB_REF::${GITHUB_REF##*/}
- name: Restore dependencies from cache
uses: actions/cache@v2
with:
path: ~/.m2
key: ${{ runner.os }}-mvn-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-mvn-
- name: Build DongTai-Java-Agent With Maven
run: |
mvn -version
mvn -B package -Dmaven.test.skip=true
- name: Upload Assets
uses: actions/upload-artifact@v3
with:
name: dongtai-agent
path: |
dongtai-agent/target/dongtai-agent.jar
dongtai-agent/src/main/resources/bin/*
- uses: manyuanrong/setup-ossutil@v2.0
with:
endpoint: ${{ secrets.CHART_OSS_ENDPOINT }}
access-key-id: ${{ secrets.OSS_KEY_ID }}
access-key-secret: ${{ secrets.OSS_KEY_SECRET }}
- name: add agent
if: ${{ steps.version.outputs.GITHUB_REF }} == develop || ${{ steps.version.outputs.GITHUB_REF }} == beta || ${{ steps.version.outputs.GITHUB_REF }} == main
run: |
cp dongtai-agent/target/dongtai-agent.jar dongtai-agent/src/main/resources/bin/ && cd dongtai-agent/src/main/resources/bin/ && tar -zcvf agent_latest.tar.gz * && cd ../../../../../
- name: Upload COS
if: ${{ steps.version.outputs.GITHUB_REF }} == develop
uses: zkqiang/tencent-cos-action@v0.1.0
with:
args: upload -rs dongtai-agent/target/dongtai-agent.jar /agent_test/java/latest/dongtai-agent.jar && upload -rs dongtai-agent/src/main/resources/bin/ /agent_test/java/latest/ && upload -rs dongtai-agent/src/main/resources/bin/agent_latest.tar.gz /agent_test/java/latest/
secret_id: ${{ secrets.TENSECRET_ID }}
secret_key: ${{ secrets.TENSECRET_KEY }}
bucket: dongtai-1251882848
region: ap-guangzhou
- name: Upload COS beta
if: ${{ steps.version.outputs.GITHUB_REF }} == beta || ${{ steps.version.outputs.GITHUB_REF }} == main
uses: zkqiang/tencent-cos-action@v0.1.0
with:
args: upload -rs dongtai-agent/target/dongtai-agent.jar /agent_${{ steps.version.outputs.GITHUB_REF }}/java/latest/dongtai-agent.jar && upload -rs dongtai-agent/src/main/resources/bin/ /agent_${{ steps.version.outputs.GITHUB_REF }}/java/latest/ && upload -rs dongtai-agent/src/main/resources/bin/agent_latest.tar.gz /agent_${{ steps.version.outputs.GITHUB_REF }}/java/latest/
secret_id: ${{ secrets.TENSECRET_ID }}
secret_key: ${{ secrets.TENSECRET_KEY }}
bucket: dongtai-1251882848
region: ap-guangzhou
- name: deploy to cluster A
uses: tscuite/kubectl-helm-action@main
env:
MAX: false
PROJECT: agent
TOKEN_SCA: ${{ secrets.TOKEN_SCA }}
KUBE_CONFIG_DATA: ${{ secrets.KUBE_CONFIG_TEST_DATA }}
- name: deploy to cluster B
uses: tscuite/kubectl-helm-action@main
env:
MAX: true
PROJECT: agent
TOKEN_SCA: ${{ secrets.MAX_TOKEN_SCA }}
KUBE_CONFIG_DATA: ${{ secrets.KUBE_CONFIG_TEST_DATA }}