-
Notifications
You must be signed in to change notification settings - Fork 194
174 lines (157 loc) · 6.4 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
# 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/[email protected]
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: |
if [ ${{ steps.version.outputs.GITHUB_REF }} = develop ] ; then
ossutil cp -rf dongtai-agent/target/dongtai-agent.jar oss://dongtai-helm-charts/agent_test/java/latest/dongtai-agent.jar --meta x-oss-object-acl:public-read
ossutil cp -rf dongtai-agent/src/main/resources/bin/ oss://dongtai-helm-charts/agent_test/java/latest/ --meta x-oss-object-acl:public-read
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 ../../../../../
ossutil cp -rf dongtai-agent/src/main/resources/bin/agent_latest.tar.gz oss://dongtai-helm-charts/agent_test/java/latest/ --meta x-oss-object-acl:public-read
else
ossutil cp -rf dongtai-agent/target/dongtai-agent.jar oss://dongtai-helm-charts/agent_${{ steps.version.outputs.GITHUB_REF }}/java/latest/dongtai-agent.jar --meta x-oss-object-acl:public-read
ossutil cp -rf dongtai-agent/src/main/resources/bin/ oss://dongtai-helm-charts/agent_${{ steps.version.outputs.GITHUB_REF }}/java/latest/ --meta x-oss-object-acl:public-read
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 ../../../../../
ossutil cp -rf dongtai-agent/src/main/resources/bin/agent_latest.tar.gz oss://dongtai-helm-charts/agent_${{ steps.version.outputs.GITHUB_REF }}/java/latest/ --meta x-oss-object-acl:public-read
fi
- 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 }}