-
Notifications
You must be signed in to change notification settings - Fork 147
175 lines (150 loc) · 6.25 KB
/
release_dongtai.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
name: Release DongTai-Server
on:
release:
types: [ created, edited ]
workflow_dispatch:
inputs:
agent_version:
required: true
type: string
server_version:
required: true
type: string
jobs:
build:
if: ${{ github.repository_owner == 'HXSecurity' }}
runs-on: ubuntu-latest
permissions:
contents: write
strategy:
max-parallel: 4
matrix:
python-version: [3.7]
steps:
- name: start-build
uses: joelwmale/webhook-action@master
with:
url: ${{ secrets.DONGTAI_WEBHOOK_URL }}
body: '{"msg_type": "interactive","card": {"config": {"wide_screen_mode": true,"enable_forward": true},"elements": [{"tag": "div","text": {"content": "状态:项目${{github.repository}}构建开始\n分支:${{github.ref}}\n流程:${{github.workflow}}\n构建编号:${{github.run_number}}\n触发事件:${{github.event_name}}\n提交人:${{github.actor}}\nSHA-1:${{github.sha}}\n","tag": "lark_md"}}]}}'
- name: Checkout
uses: actions/checkout@v2
- name: Set the value
id: release
run: |
TAG_NAME=${{ github.event.release.tag_name }}
ID=`echo ${TAG_NAME##v}`
if [ -z "${{ inputs.server_version }}" ]
then
echo "variable is empty"
else
ID=${{ inputs.server_version }}
fi
echo "iast_version=$ID" >> $GITHUB_ENV
- name: Generate version file
run: |
bash .github/workflows/version_update.sh "${{ env.iast_version }}"
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DONGTAI_DOCKERHUB_USERNAME }}
password: ${{ secrets.DONGTAI_DOCKERHUB_TOKEN }}
- name: Login to Aliyun Registry
uses: docker/login-action@v1
with:
registry: ${{ secrets.ALIYUN_REGISTRY_HONGKONG }}
username: ${{ secrets.ALIYUN_DOCKERHUB_USER }}
password: ${{ secrets.ALIYUN_DOCKERHUB_PASSWORD }}
- run: |
echo "REPLACE INTO project_version_control (version, component_name, component_version_hash) VALUES('${{ env.iast_version }}', '${{ github.event.repository.name }}', '${GITHUB_SHA}');" >> ./deploy/docker/version.sql
- name: Upload COS java
uses: zkqiang/[email protected]
with:
args: download -rs /agent/java/latest/ ./ --include "*.jar"
secret_id: ${{ secrets.TENSECRET_ID }}
secret_key: ${{ secrets.TENSECRET_KEY }}
bucket: dongtai-helm-charts-1251882848
region: ap-hongkong
- name: Upload COS python
uses: zkqiang/[email protected]
with:
args: download -rs /agent/python/ ./ --include "*.tar.gz"
secret_id: ${{ secrets.TENSECRET_ID }}
secret_key: ${{ secrets.TENSECRET_KEY }}
bucket: dongtai-helm-charts-1251882848
region: ap-hongkong
- name: Upload COS php
uses: zkqiang/[email protected]
with:
args: download -rs /agent/php/ ./ --include "*.tar.gz"
secret_id: ${{ secrets.TENSECRET_ID }}
secret_key: ${{ secrets.TENSECRET_KEY }}
bucket: dongtai-helm-charts-1251882848
region: ap-hongkong
- name: Setup QEMU
uses: docker/setup-qemu-action@v2
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build and push
uses: docker/build-push-action@v3
with:
file: Dockerfile
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: |
dongtai/dongtai-server:latest
dongtai/dongtai-server:${{ env.iast_version }}
- name: finish build
uses: joelwmale/webhook-action@master
with:
url: ${{ secrets.DONGTAI_WEBHOOK_URL }}
body: '{"msg_type": "interactive","card": {"config": {"wide_screen_mode": true,"enable_forward": true},"elements": [{"tag": "div","text": {"content": "状态:项目${{github.repository}}构建成功\n分支:${{github.ref}}\n流程:${{github.workflow}}\n构建编号:${{github.run_number}}\n触发事件:${{github.event_name}}\n提交人:${{github.actor}}\nSHA-1:${{github.sha}}\n","tag": "lark_md"}}]}}'
helm:
if: ${{ github.repository_owner == 'HXSecurity' }}
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set the value
id: release
run: |
TAG_NAME=${{ github.event.release.tag_name }}
ID=`echo ${TAG_NAME##v}`
if [ -z "${{ inputs.server_version }}" ]
then
echo "variable is empty"
else
ID=${{ inputs.server_version }}
fi
echo "iast_version=$ID" >> $GITHUB_ENV
- uses: azure/setup-helm@v1
with:
version: 'latest'
id: install
- name: Get the release version
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/}
- name: Download existed repo files
run: |
sed -i "s#tag: latest#tag: ${{ env.iast_version }}#g" deploy/kubernetes/helm/values.yaml
- name: Upload COS php
uses: zkqiang/[email protected]
with:
args: download -rs /iast/ ~/helm/repo/ --include dongtai-iast-*.tgz --ignore "index.yaml"
secret_id: ${{ secrets.TENSECRET_ID }}
secret_key: ${{ secrets.TENSECRET_KEY }}
bucket: dongtai-helm-charts-1251882848
region: ap-hongkong
- name: Create helm package
run: |
helm package deploy/kubernetes/helm -d ~/helm/repo --app-version ${{ env.iast_version }} --version ${{ env.iast_version }}
helm repo index ~/helm/repo/ --url ${{ secrets.DONGTAI_IAST_CHART_REPO_URL }}
- name: Upload COS 2
uses: zkqiang/[email protected]
with:
args: upload -rs ~/helm/repo/dongtai-iast-${{ env.iast_version }}.tgz /iast/ && upload -rs ~/helm/repo/index.yaml /iast/
secret_id: ${{ secrets.TENSECRET_ID }}
secret_key: ${{ secrets.TENSECRET_KEY }}
bucket: dongtai-helm-charts-1251882848
region: ap-hongkong