-
Notifications
You must be signed in to change notification settings - Fork 1.8k
224 lines (200 loc) · 7.44 KB
/
ci-merged.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
name: MERGE PIPELINE
on:
pull_request_target:
branches:
- main
- 'branch-[0-9].[0-9]'
types:
- closed
permissions:
pull-requests: write
issues: write
actions: write
jobs:
backport:
runs-on: ubuntu-latest
if: >
github.event.pull_request.merged == true &&
github.base_ref == 'main' &&
github.repository == 'StarRocks/starrocks' &&
!contains(github.event.pull_request.title, 'cherry-pick') &&
!contains(github.event.pull_request.title, 'backport') && (
contains(github.event.pull_request.labels.*.name, '3.1') ||
contains(github.event.pull_request.labels.*.name, '3.0') ||
contains(github.event.pull_request.labels.*.name, '2.5') ||
contains(github.event.pull_request.labels.*.name, '2.4') )
env:
PR_NUMBER: ${{ github.event.number }}
steps:
- name: backport branch-3.1
if: contains(github.event.pull_request.labels.*.name, '3.1')
uses: thollander/actions-comment-pull-request@v1
with:
message: |
@Mergifyio backport branch-3.1
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions-ecosystem/action-remove-labels@v1
if: contains(github.event.pull_request.labels.*.name, '3.1')
with:
labels: '3.1'
- name: backport branch-3.0
if: contains(github.event.pull_request.labels.*.name, '3.0')
uses: thollander/actions-comment-pull-request@v1
with:
message: |
@Mergifyio backport branch-3.0
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions-ecosystem/action-remove-labels@v1
if: contains(github.event.pull_request.labels.*.name, '3.0')
with:
labels: '3.0'
- name: backport branch-2.5
if: contains(github.event.pull_request.labels.*.name, '2.5')
uses: thollander/actions-comment-pull-request@v1
with:
message: |
@Mergifyio backport branch-2.5
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions-ecosystem/action-remove-labels@v1
if: contains(github.event.pull_request.labels.*.name, '2.5')
with:
labels: '2.5'
- name: backport branch-2.4
if: contains(github.event.pull_request.labels.*.name, '2.4')
uses: thollander/actions-comment-pull-request@v1
with:
message: |
@Mergifyio backport branch-2.4
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions-ecosystem/action-remove-labels@v1
if: contains(github.event.pull_request.labels.*.name, '2.4')
with:
labels: '2.4'
thirdparty-update-image:
runs-on: [self-hosted, normal]
name: Thirdparty Update Image
if: github.event.pull_request.merged == true
continue-on-error: false
strategy:
fail-fast: false
matrix:
linux: [ centos7, ubuntu ]
env:
PR_NUMBER: ${{ github.event.number }}
BRANCH: ${{ github.base_ref }}
REPO: ${{ github.repository }}
steps:
- name: clean
run: |
rm -rf ${{ github.workspace }}
mkdir -p ${{ github.workspace }}
- uses: dorny/paths-filter@v2
id: changes
with:
filters: |
thirdparty:
- 'thirdparty/**'
- 'docker/dockerfiles/dev-env/dev-env.Dockerfile'
- name: update image (${{ matrix.linux }})
if: steps.changes.outputs.thirdparty == 'true'
run: |
rm -rf ./ci-tool && cp -rf /var/lib/ci-tool ./ci-tool && cd ci-tool && git pull && source lib/init.sh
./bin/elastic-update-image.sh $BRANCH $PR_NUMBER ${{ matrix.linux }}
- name: Clean ENV
if: always()
run: |
rm -rf ${{ github.workspace }}/*
close_msg:
runs-on: [self-hosted, normal]
if: >
github.event.pull_request.merged == true &&
github.base_ref == 'main' &&
github.repository == 'StarRocks/starrocks'
env:
PR_NUMBER: ${{ github.event.number }}
steps:
- name: commit_sha
id: commit_sha
run: |
set -x
commit_sha=`curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/${{ github.repository }}/pulls/${PR_NUMBER} 2>/dev/null \
| jq .merge_commit_sha`
commit_sha=$(echo ${commit_sha//\"})
echo "commit_sha=${commit_sha}" >> $GITHUB_OUTPUT
- name: update merged coverage
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
rm -rf ./ci-tool && cp -rf /var/lib/ci-tool ./ci-tool && cd ci-tool && git pull && source lib/init.sh
./bin/upload_cov_after_merge.sh --pr ${PR_NUMBER} --commit ${{ steps.commit_sha.outputs.commit_sha }}
- name: Clean ENV
if: always()
run: |
rm -rf ${{ github.workspace }}/*
clean_ci_workflow:
runs-on: ubuntu-latest
if: >
github.event.pull_request.merged != true
env:
PR_NUMBER: ${{ github.event.number }}
REPO: ${{ github.repository }}
BRANCH: ${{ github.base_ref }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: cancel
run: |
if [[ "${BRANCH}" == "main" ]]; then
yaml=ci-pipeline.yml
else
yaml=ci-pipeline-branch.yml
fi
gh run list --workflow ${yaml} -R ${REPO} -b ${GITHUB_HEAD_REF} --json databaseId -q '.[].databaseId' | xargs gh run cancel -R ${REPO} || true
update_backport_merged_msg:
runs-on: [ self-hosted, quick ]
if: >
github.base_ref != 'main' && github.event.pull_request.merged == true
env:
PR_NUMBER: ${{ github.event.number }}
steps:
- name: prepare merge label
if: >
!contains(github.event.pull_request.labels.*.name, 'sync') &&
contains(github.event.pull_request.title, '(backport #')
env:
GH_TOKEN: ${{ secrets.PAT }}
run: |
LABEL="${GITHUB_BASE_REF##*-}-merged"
gh label create "${LABEL}" -R ${GITHUB_REPOSITORY} -c 98C1D7 -f
- name: add merge label
if: >
always() && !contains(github.event.pull_request.labels.*.name, 'sync') &&
contains(github.event.pull_request.title, '(backport #')
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_TITLE: ${{ github.event.pull_request.title }}
run: |
LABEL="${GITHUB_BASE_REF##*-}-merged"
ORI_PR=$(echo "${PR_TITLE}" | grep -oP '\(backport #\K\d+' | tail -n 1)
gh pr edit ${ORI_PR} -R ${GITHUB_REPOSITORY} --add-label "${LABEL}"
- name: prepare version label
id: prepare_version_label
if: always()
env:
GH_TOKEN: ${{ secrets.PAT }}
run: |
rm -rf ./ci-tool && cp -rf /var/lib/ci-tool ./ci-tool && cd ci-tool && git pull >/dev/null
version=$(./scripts/get_next_release_tag.sh)
version_label="version:${version}"
echo "LABEL=${version_label}" >> $GITHUB_OUTPUT
gh label create "${version_label}" -R ${GITHUB_REPOSITORY} -c 1d76db -f
- name: add version label
if: always()
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION_LABEL: ${{ steps.prepare_version_label.outputs.LABEL }}
run: |
gh pr edit ${PR_NUMBER} -R ${GITHUB_REPOSITORY} --add-label "${VERSION_LABEL}"