Skip to content

Commit a418b9e

Browse files
authored
chore: add UPGRADE_ADDON_EXTRA_ENV for deploy (#730)
1 parent f9b593c commit a418b9e

2 files changed

Lines changed: 97 additions & 12 deletions

File tree

.github/utils/manifests_charts_addon_upgrade.sh

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,51 +56,63 @@ upgrade_charts_addon() {
5656
is_enterprise=$(yq e "."${chart_name}"[0].isEnterprise" ${MANIFESTS_FILE})
5757
chart_version_list=$(yq e "."${chart_name}"[].version" ${MANIFESTS_FILE})
5858
chart_version=""
59+
chart_index=0
5960
# compare same version
6061
for chartVersion in $(echo "$chart_version_list"); do
6162
if [[ "$chartVersion" == "$deploy_chart_version" ]]; then
6263
chart_version="$chartVersion"
64+
is_enterprise=$(yq e "."${chart_name}"[${chart_index}].isEnterprise" ${MANIFESTS_FILE})
6365
break
6466
fi
67+
chart_index=$(( $chart_index + 1 ))
6568
done
6669

6770
# compare same head version
6871
if [[ -z "$chart_version" ]]; then
72+
chart_index=0
6973
for chart_version_tmp in $(echo "$chart_version_list"); do
70-
chart_version_tmp=${chartVersion%-*}
74+
chart_version_compare=${chart_version_tmp%-*}
7175
deploy_chart_version_tmp=${deploy_chart_version%-*}
72-
if [[ "$chart_version_tmp" == "$deploy_chart_version_tmp" ]]; then
73-
chart_version="$chartVersion"
76+
if [[ "$chart_version_compare" == "$deploy_chart_version_tmp" ]]; then
77+
chart_version="$chart_version_tmp"
78+
is_enterprise=$(yq e "."${chart_name}"[${chart_index}].isEnterprise" ${MANIFESTS_FILE})
7479
break
7580
fi
81+
chart_index=$(( $chart_index + 1 ))
7682
done
7783
fi
7884

7985
# compare same head2 version
8086
if [[ -z "$chart_version" ]]; then
87+
chart_index=0
8188
for chart_version_tmp in $(echo "$chart_version_list"); do
82-
chart_version_tmp=${chartVersion%-*}
83-
chart_version_tmp=${chart_version_tmp%.*}
89+
chart_version_compare=${chart_version_tmp%-*}
90+
chart_version_compare=${chart_version_compare%.*}
8491
deploy_chart_version_tmp=${deploy_chart_version%-*}
8592
deploy_chart_version_tmp=${deploy_chart_version_tmp%.*}
86-
if [[ "$chart_version_tmp" == "$deploy_chart_version_tmp" ]]; then
87-
chart_version="$chartVersion"
93+
if [[ "$chart_version_compare" == "$deploy_chart_version_tmp" ]]; then
94+
chart_version="$chart_version_tmp"
95+
is_enterprise=$(yq e "."${chart_name}"[${chart_index}].isEnterprise" ${MANIFESTS_FILE})
8896
break
8997
fi
98+
chart_index=$(( $chart_index + 1 ))
9099
done
91100
fi
92101

93102
# compare with kubeblocks same head2 version
94103
if [[ -z "$chart_version" ]]; then
95-
for chartVersion in $(echo "$chart_version_list"); do
96-
chart_version_tmp=${chartVersion%-*}
97-
chart_version_tmp=${chart_version_tmp%.*}
104+
chart_index=0
105+
for chart_version_tmp in $(echo "$chart_version_list"); do
106+
chart_version_compare=${chart_version_tmp%-*}
107+
chart_version_compare=${chart_version_compare%.*}
98108
kubeblocks_version_tmp=${kubeblocks_version%-*}
99109
kubeblocks_version_tmp=${kubeblocks_version_tmp%.*}
100-
if [[ "$chart_version_tmp" == "$kubeblocks_version_tmp" ]]; then
101-
chart_version="$chartVersion"
110+
if [[ "$chart_version_compare" == "$kubeblocks_version_tmp" ]]; then
111+
chart_version="$chart_version_tmp"
112+
is_enterprise=$(yq e "."${chart_name}"[${chart_index}].isEnterprise" ${MANIFESTS_FILE})
102113
break
103114
fi
115+
chart_index=$(( $chart_index + 1 ))
104116
done
105117
fi
106118

.github/workflows/deploy-cloud.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ on:
5353
type: boolean
5454
required: false
5555
default: false
56+
UPGRADE_ADDON_EXTRA_ENV:
57+
description: "The cloud env name of upgrade addon extra "
58+
type: string
59+
required: false
60+
default: ''
5661

5762

5863
env:
@@ -283,3 +288,71 @@ jobs:
283288
run: |
284289
MANIFESTS_FILE="./manifests/deploy-manifests.yaml"
285290
bash ${{ github.workspace }}/apecloud-cd/.github/utils/manifests_charts_addon_upgrade.sh "${MANIFESTS_FILE}"
291+
292+
293+
upgrade-addon-idc:
294+
if: ${{ inputs.UPGRADE_ADDON && inputs.UPGRADE_ADDON_EXTRA_ENV != '' }}
295+
permissions:
296+
contents: 'read'
297+
id-token: 'write'
298+
needs: [ deploy-cloud ]
299+
runs-on: ubuntu-latest
300+
steps:
301+
- name: Checkout Code
302+
uses: actions/checkout@v4
303+
304+
- name: Checkout apecloud-cd Code
305+
uses: actions/checkout@v4
306+
with:
307+
repository: apecloud/apecloud-cd
308+
path: ./apecloud-cd
309+
ref: ${{ inputs.APECD_REF }}
310+
311+
- uses: azure/setup-kubectl@v3
312+
with:
313+
version: "${{ inputs.KUBECTL_VERSION }}"
314+
315+
- name: Install Helm
316+
uses: azure/setup-helm@v3
317+
with:
318+
version: ${{ env.HELM_VERSION }}
319+
320+
- name: Configure Context ${{ inputs.UPGRADE_ADDON_EXTRA_ENV }}
321+
run: |
322+
mkdir -p $HOME/.kube
323+
touch $HOME/.kube/config
324+
CLOUD_ENV_NAME="${{ inputs.UPGRADE_ADDON_EXTRA_ENV }}"
325+
case "$CLOUD_ENV_NAME" in
326+
dev)
327+
echo '${{ env.ACK_KUBECONFIG_DEV }}' > $HOME/.kube/config
328+
;;
329+
demo)
330+
echo '${{ env.ACK_KUBECONFIG_DEMO }}' > $HOME/.kube/config
331+
;;
332+
idc)
333+
echo '${{ env.IDC_KUBECONFIG }}' > $HOME/.kube/config
334+
;;
335+
idc1)
336+
echo '${{ env.IDC_KUBECONFIG_1 }}' > $HOME/.kube/config
337+
;;
338+
idc2)
339+
echo '${{ env.IDC_KUBECONFIG_2 }}' > $HOME/.kube/config
340+
;;
341+
idc4)
342+
echo '${{ env.IDC_KUBECONFIG_4 }}' > $HOME/.kube/config
343+
;;
344+
prod)
345+
echo '${{ env.ACK_KUBECONFIG_PROD }}' > $HOME/.kube/config
346+
;;
347+
intl_prod)
348+
echo '${{ env.ACK_KUBECONFIG_INTL_PROD }}' > $HOME/.kube/config
349+
;;
350+
*)
351+
echo '${{ env.ACK_KUBECONFIG }}' > $HOME/.kube/config
352+
;;
353+
esac
354+
355+
- name: Upgrade Addon
356+
run: |
357+
MANIFESTS_FILE="./manifests/deploy-manifests.yaml"
358+
bash ${{ github.workspace }}/apecloud-cd/.github/utils/manifests_charts_addon_upgrade.sh "${MANIFESTS_FILE}"

0 commit comments

Comments
 (0)