Skip to content

Commit 0bb07ef

Browse files
authored
chart(build): Push chart to Docker Hub OCI-based registry (#2319)
Signed-off-by: Viet Nguyen Duc <[email protected]>
1 parent 582fb2c commit 0bb07ef

File tree

5 files changed

+80
-17
lines changed

5 files changed

+80
-17
lines changed

.github/workflows/deploy.yml

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,20 @@ jobs:
101101
max_attempts: 3
102102
retry_wait_seconds: 60
103103
command: PLATFORMS="${PLATFORMS}" VERSION="${GRID_VERSION}" BUILD_DATE=${BUILD_DATE} make build
104+
- name: Build Helm chart
105+
uses: nick-invision/retry@master
106+
with:
107+
timeout_minutes: 5
108+
max_attempts: 3
109+
retry_wait_seconds: 10
110+
command: |
111+
SET_VERSION=false make chart_build
112+
echo "CHART_PACKAGE_PATH=$(cat /tmp/selenium_chart_version)" >> $GITHUB_ENV
113+
echo "CHART_FILE_NAME=$(basename $(cat /tmp/selenium_chart_version))" >> $GITHUB_ENV
104114
- name: Login Docker Hub
105-
run: docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD"
115+
run: |
116+
docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD"
117+
helm registry login registry-1.docker.io -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD"
106118
env:
107119
DOCKER_USERNAME: ${{secrets.DOCKER_USERNAME}}
108120
DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}}
@@ -111,25 +123,31 @@ jobs:
111123
with:
112124
timeout_minutes: 20
113125
max_attempts: 3
126+
retry_wait_seconds: 120
114127
command: VERSION="${GRID_VERSION}" BUILD_DATE=${BUILD_DATE} make release
115128
- name: Tag images as latest
116-
uses: nick-invision/retry@master
117-
with:
118-
timeout_minutes: 20
119-
max_attempts: 3
120-
command: VERSION="${GRID_VERSION}" BUILD_DATE=${BUILD_DATE} make tag_latest
129+
run: VERSION="${GRID_VERSION}" BUILD_DATE=${BUILD_DATE} make tag_latest
121130
- name: Deploy latest tag
122131
uses: nick-invision/retry@master
123132
with:
124133
timeout_minutes: 20
125134
max_attempts: 3
135+
retry_wait_seconds: 120
126136
command: VERSION="${GRID_VERSION}" BUILD_DATE=${BUILD_DATE} make release_latest
127137
- name: Tag browser images
128138
uses: nick-invision/retry@master
129139
with:
130140
timeout_minutes: 20
131141
max_attempts: 3
142+
retry_wait_seconds: 120
132143
command: VERSION="${GRID_VERSION}" BUILD_DATE=${BUILD_DATE} PUSH_IMAGE=true make tag_and_push_browser_images
144+
- name: Push Helm chart to registry
145+
uses: nick-invision/retry@master
146+
with:
147+
timeout_minutes: 20
148+
max_attempts: 3
149+
retry_wait_seconds: 120
150+
command: make chart_release
133151
- name: Delete previous nightly tag & release if any
134152
uses: dev-drprasad/delete-tag-and-release@master
135153
with:

.github/workflows/nightly.yml

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,23 +88,39 @@ jobs:
8888
max_attempts: 3
8989
retry_wait_seconds: 60
9090
command: PLATFORMS="${PLATFORMS}" VERSION="${GRID_VERSION}" BUILD_DATE=${BUILD_DATE} make build
91+
- name: Build Helm chart
92+
uses: nick-invision/retry@master
93+
with:
94+
timeout_minutes: 5
95+
max_attempts: 3
96+
retry_wait_seconds: 10
97+
command: |
98+
make chart_build_nightly
99+
echo "CHART_PACKAGE_PATH=$(cat /tmp/selenium_chart_version)" >> $GITHUB_ENV
100+
echo "CHART_FILE_NAME=$(basename $(cat /tmp/selenium_chart_version))" >> $GITHUB_ENV
91101
- name: Login Docker Hub
92-
run: docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD"
102+
run: |
103+
docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD"
104+
helm registry login registry-1.docker.io -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD"
93105
env:
94106
DOCKER_USERNAME: ${{secrets.DOCKER_USERNAME}}
95107
DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}}
96108
- name: Tag images as nightly
109+
run: VERSION="${GRID_VERSION}" BUILD_DATE=${BUILD_DATE} make tag_nightly
110+
- name: Deploy nightly tag
97111
uses: nick-invision/retry@master
98112
with:
99113
timeout_minutes: 20
100114
max_attempts: 3
101-
command: VERSION="${GRID_VERSION}" BUILD_DATE=${BUILD_DATE} make tag_nightly
102-
- name: Deploy nightly tag
115+
retry_wait_seconds: 120
116+
command: VERSION="${GRID_VERSION}" BUILD_DATE=${BUILD_DATE} make release_nightly
117+
- name: Push Helm chart to registry
103118
uses: nick-invision/retry@master
104119
with:
105120
timeout_minutes: 20
106121
max_attempts: 3
107-
command: VERSION="${GRID_VERSION}" BUILD_DATE=${BUILD_DATE} make release_nightly
122+
retry_wait_seconds: 120
123+
command: make chart_release
108124
- name: Get current latest tag
109125
run: echo "LATEST_TAG=$(git describe --tags --abbrev=0 --exclude=nightly --exclude=selenium-grid*)" >> $GITHUB_ENV
110126
- name: Display latest tag
@@ -122,11 +138,6 @@ jobs:
122138
check-latest: true
123139
- name: Update tag in docs and files
124140
run: ./update_tag_in_docs_and_files.sh ${LATEST_TAG} ${NEXT_TAG}
125-
- name: Build and lint charts
126-
run: |
127-
make chart_build_nightly
128-
echo "CHART_PACKAGE_PATH=$(cat /tmp/selenium_chart_version)" >> $GITHUB_ENV
129-
echo "CHART_FILE_NAME=$(basename $(cat /tmp/selenium_chart_version))" >> $GITHUB_ENV
130141
- name: Delete previous nightly tag if any
131142
uses: cb80/delrel@main
132143
with:

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,9 @@ chart_build_nightly:
731731
chart_build:
732732
VERSION=$(TAG_VERSION) ./tests/charts/make/chart_build.sh
733733

734+
chart_release:
735+
NAMESPACE=$(NAMESPACE) ./tests/charts/make/chart_release.sh
736+
734737
test_video_integrity:
735738
# Using ffmpeg to verify file integrity
736739
# https://superuser.com/questions/100288/how-can-i-check-the-integrity-of-a-video-file-avi-mpeg-mp4

tests/charts/make/chart_build.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/bash
2+
set -x
23

4+
SET_VERSION=${SET_VERSION:-"true"}
35
CHART_PATH=${CHART_PATH:-"charts/selenium-grid"}
46
# Function to be executed on command failure
57
on_failure() {
@@ -24,14 +26,21 @@ fi
2426

2527
python3 -m pip install yamale==4.0.4 \
2628
yamllint==1.33.0 \
27-
| grep -v 'Requirement already satisfied'
29+
| grep -v 'Requirement already satisfied' || true
2830

2931
cd ..
3032
rm -rf ${CHART_PATH}/Chart.lock
3133
ct lint --all --config tests/charts/config/ct.yaml
3234
# Helm dependencies build and lint is done by `ct lint` command
3335
rm -rf ${CHART_PATH}/../*.tgz
34-
helm package ${CHART_PATH} --version ${VERSION} --destination ${CHART_PATH}/..
36+
37+
if [ "${SET_VERSION}" = "true" ]; then
38+
ADD_VERSION="--version ${VERSION}"
39+
else
40+
ADD_VERSION=""
41+
fi
42+
43+
helm package ${CHART_PATH} ${ADD_VERSION} --destination ${CHART_PATH}/..
3544

3645
readlink -f ${CHART_PATH}/../*.tgz > /tmp/selenium_chart_version
3746
cat /tmp/selenium_chart_version

tests/charts/make/chart_release.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
set -x
3+
4+
NAMESPACE=${NAMESPACE:-"selenium"}
5+
# Function to be executed on command failure
6+
on_failure() {
7+
local exit_status=$?
8+
echo "There is step failed with exit status $exit_status"
9+
exit $exit_status
10+
}
11+
12+
# Trap ERR signal and call on_failure function
13+
trap 'on_failure' ERR
14+
15+
CHART_PACKAGE_PATH=$(cat /tmp/selenium_chart_version)
16+
if [ -z "${CHART_PACKAGE_PATH}" ] || [ ! -f "${CHART_PACKAGE_PATH}" ]; then
17+
echo "Chart package path is empty. Please trigger chart_build.sh before this script."
18+
exit 1
19+
fi
20+
21+
echo "Pushing chart package to the registry"
22+
helm push ${CHART_PACKAGE_PATH} oci://registry-1.docker.io/${NAMESPACE}

0 commit comments

Comments
 (0)