-
Notifications
You must be signed in to change notification settings - Fork 277
129 lines (111 loc) · 4.3 KB
/
Copy pathcherry-pick.yml
File metadata and controls
129 lines (111 loc) · 4.3 KB
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
name: Cherry Pick Or Label Pick
on:
issue_comment:
types: [created]
env:
GH_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
GO_VERSION: "1.25"
jobs:
trigger-mode:
if: github.event.issue.pull_request != '' && contains(github.event.comment.body, '/cherry-pick')
runs-on: ubuntu-latest
outputs:
trigger-mode: ${{ steps.get_trigger_mode.outputs.trigger_mode }}
steps:
- uses: actions/checkout@v4
with:
token: ${{ env.GH_TOKEN }}
fetch-depth: 0
- name: Simulation Cherry Pick
uses: apecloud-inc/gha-cherry-pick@v2
env:
GITHUB_TOKEN: ${{ env.GH_TOKEN }}
- name: Get trigger mode
id: get_trigger_mode
run: |
TARGET_BRANCH=$(jq -r ".comment.body" "$GITHUB_EVENT_PATH" | awk '{ print $2 }' | tr -d '[:space:]')
echo "TARGET_BRANCH:$TARGET_BRANCH"
TRIGGER_MODE=`bash .github/utils/utils.sh --type 6 \
--branch-name "${TARGET_BRANCH}" \
--base-branch "origin/${TARGET_BRANCH}"`
echo "TRIGGER_MODE:$TRIGGER_MODE"
echo trigger_mode=$TRIGGER_MODE >> $GITHUB_OUTPUT
cherry-pick-pre-check:
needs: [ trigger-mode ]
if: contains(needs.trigger-mode.outputs.trigger-mode, '[test]')
runs-on: ubuntu-latest
timeout-minutes: ${{ (matrix.ops == 'lint' && 6) || (matrix.ops == 'manifests' && 5) || 2 }}
strategy:
fail-fast: true
matrix:
ops: [ 'manifests', 'mod-vendor', 'generate', 'lint' ]
steps:
- uses: actions/checkout@v4
with:
token: ${{ env.GH_TOKEN }}
fetch-depth: 0
- name: Simulation Cherry Pick
uses: apecloud-inc/gha-cherry-pick@v2
env:
GITHUB_TOKEN: ${{ env.GH_TOKEN }}
- name: install lib
run: |
sudo rm -f /etc/apt/sources.list.d/microsoft-prod.list
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
libbtrfs-dev \
libdevmapper-dev
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "${{ env.GO_VERSION }}"
- name: Install golangci-lint
if: matrix.ops == 'lint'
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.8.0
- name: make ${{ matrix.ops }}
run: |
BEFORE_PICK=$(git rev-parse HEAD)
make ${{ matrix.ops }}
FILE_CHANGES=`git diff --name-only ${BEFORE_PICK}`
if [[ ("${{ matrix.ops }}" == 'generate' || "${{ matrix.ops }}" == 'manifests') && -n "$FILE_CHANGES" ]]; then
echo $FILE_CHANGES
echo "make "${{ matrix.ops }}" causes inconsistent files"
exit 1
fi
cherry-pick:
needs: [ trigger-mode, cherry-pick-pre-check ]
if: always() && github.event.issue.pull_request != ''
&& contains(github.event.comment.body, '/cherry-pick')
&& needs.trigger-mode.result == 'success'
runs-on: ubuntu-latest
steps:
- name: cherry-pick pre check
run: |
if [[ "${{ needs.cherry-pick-pre-check.result }}" == "failure" || "${{ needs.cherry-pick-pre-check.result }}" == "cancelled" ]]; then
echo "cherry pick pre check fail"
exit 1
fi
- uses: actions/checkout@v4
with:
token: ${{ env.GH_TOKEN }}
fetch-depth: 0
- name: Automatic Cherry Pick
uses: apecloud-inc/gha-cherry-pick@v1
env:
GITHUB_TOKEN: ${{ env.GH_TOKEN }}
pick-meassge:
needs: [ cherry-pick ]
if: ${{ failure() || cancelled() }}
uses: apecloud/apecloud-cd/.github/workflows/feishui-message.yml@v0.1.88
with:
TYPE: "5"
BOT_TYPE: "specify"
BOT_WEBHOOK: "${{ vars.CHERRY_PICK_BOT_WEBHOOK }}"
CONTENT: " ${{ github.repository }} ${{ github.event.comment.body }} error"
PR_NUMBER: "${{ github.event.issue.number }}"
secrets: inherit
label-pick:
if: ${{ github.event.issue.pull_request != '' && (contains(github.event.comment.body, '/pick') || contains(github.event.comment.body, '/nopick')) && ! contains(github.event.comment.body, 'Auto Cherry-pick Instructions') }}
uses: apecloud/apecloud-cd/.github/workflows/pull-request-label-pick.yml@v0.1.88
secrets: inherit