Skip to content

Commit

Permalink
chart(build): Push chart to Docker Hub OCI-based registry (#2319)
Browse files Browse the repository at this point in the history
Signed-off-by: Viet Nguyen Duc <[email protected]>
  • Loading branch information
VietND96 authored Jul 22, 2024
1 parent 582fb2c commit 0bb07ef
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 17 deletions.
30 changes: 24 additions & 6 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,20 @@ jobs:
max_attempts: 3
retry_wait_seconds: 60
command: PLATFORMS="${PLATFORMS}" VERSION="${GRID_VERSION}" BUILD_DATE=${BUILD_DATE} make build
- name: Build Helm chart
uses: nick-invision/retry@master
with:
timeout_minutes: 5
max_attempts: 3
retry_wait_seconds: 10
command: |
SET_VERSION=false make chart_build
echo "CHART_PACKAGE_PATH=$(cat /tmp/selenium_chart_version)" >> $GITHUB_ENV
echo "CHART_FILE_NAME=$(basename $(cat /tmp/selenium_chart_version))" >> $GITHUB_ENV
- name: Login Docker Hub
run: docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD"
run: |
docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD"
helm registry login registry-1.docker.io -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD"
env:
DOCKER_USERNAME: ${{secrets.DOCKER_USERNAME}}
DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}}
Expand All @@ -111,25 +123,31 @@ jobs:
with:
timeout_minutes: 20
max_attempts: 3
retry_wait_seconds: 120
command: VERSION="${GRID_VERSION}" BUILD_DATE=${BUILD_DATE} make release
- name: Tag images as latest
uses: nick-invision/retry@master
with:
timeout_minutes: 20
max_attempts: 3
command: VERSION="${GRID_VERSION}" BUILD_DATE=${BUILD_DATE} make tag_latest
run: VERSION="${GRID_VERSION}" BUILD_DATE=${BUILD_DATE} make tag_latest
- name: Deploy latest tag
uses: nick-invision/retry@master
with:
timeout_minutes: 20
max_attempts: 3
retry_wait_seconds: 120
command: VERSION="${GRID_VERSION}" BUILD_DATE=${BUILD_DATE} make release_latest
- name: Tag browser images
uses: nick-invision/retry@master
with:
timeout_minutes: 20
max_attempts: 3
retry_wait_seconds: 120
command: VERSION="${GRID_VERSION}" BUILD_DATE=${BUILD_DATE} PUSH_IMAGE=true make tag_and_push_browser_images
- name: Push Helm chart to registry
uses: nick-invision/retry@master
with:
timeout_minutes: 20
max_attempts: 3
retry_wait_seconds: 120
command: make chart_release
- name: Delete previous nightly tag & release if any
uses: dev-drprasad/delete-tag-and-release@master
with:
Expand Down
29 changes: 20 additions & 9 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,23 +88,39 @@ jobs:
max_attempts: 3
retry_wait_seconds: 60
command: PLATFORMS="${PLATFORMS}" VERSION="${GRID_VERSION}" BUILD_DATE=${BUILD_DATE} make build
- name: Build Helm chart
uses: nick-invision/retry@master
with:
timeout_minutes: 5
max_attempts: 3
retry_wait_seconds: 10
command: |
make chart_build_nightly
echo "CHART_PACKAGE_PATH=$(cat /tmp/selenium_chart_version)" >> $GITHUB_ENV
echo "CHART_FILE_NAME=$(basename $(cat /tmp/selenium_chart_version))" >> $GITHUB_ENV
- name: Login Docker Hub
run: docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD"
run: |
docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD"
helm registry login registry-1.docker.io -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD"
env:
DOCKER_USERNAME: ${{secrets.DOCKER_USERNAME}}
DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}}
- name: Tag images as nightly
run: VERSION="${GRID_VERSION}" BUILD_DATE=${BUILD_DATE} make tag_nightly
- name: Deploy nightly tag
uses: nick-invision/retry@master
with:
timeout_minutes: 20
max_attempts: 3
command: VERSION="${GRID_VERSION}" BUILD_DATE=${BUILD_DATE} make tag_nightly
- name: Deploy nightly tag
retry_wait_seconds: 120
command: VERSION="${GRID_VERSION}" BUILD_DATE=${BUILD_DATE} make release_nightly
- name: Push Helm chart to registry
uses: nick-invision/retry@master
with:
timeout_minutes: 20
max_attempts: 3
command: VERSION="${GRID_VERSION}" BUILD_DATE=${BUILD_DATE} make release_nightly
retry_wait_seconds: 120
command: make chart_release
- name: Get current latest tag
run: echo "LATEST_TAG=$(git describe --tags --abbrev=0 --exclude=nightly --exclude=selenium-grid*)" >> $GITHUB_ENV
- name: Display latest tag
Expand All @@ -122,11 +138,6 @@ jobs:
check-latest: true
- name: Update tag in docs and files
run: ./update_tag_in_docs_and_files.sh ${LATEST_TAG} ${NEXT_TAG}
- name: Build and lint charts
run: |
make chart_build_nightly
echo "CHART_PACKAGE_PATH=$(cat /tmp/selenium_chart_version)" >> $GITHUB_ENV
echo "CHART_FILE_NAME=$(basename $(cat /tmp/selenium_chart_version))" >> $GITHUB_ENV
- name: Delete previous nightly tag if any
uses: cb80/delrel@main
with:
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,9 @@ chart_build_nightly:
chart_build:
VERSION=$(TAG_VERSION) ./tests/charts/make/chart_build.sh

chart_release:
NAMESPACE=$(NAMESPACE) ./tests/charts/make/chart_release.sh

test_video_integrity:
# Using ffmpeg to verify file integrity
# https://superuser.com/questions/100288/how-can-i-check-the-integrity-of-a-video-file-avi-mpeg-mp4
Expand Down
13 changes: 11 additions & 2 deletions tests/charts/make/chart_build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash
set -x

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

python3 -m pip install yamale==4.0.4 \
yamllint==1.33.0 \
| grep -v 'Requirement already satisfied'
| grep -v 'Requirement already satisfied' || true

cd ..
rm -rf ${CHART_PATH}/Chart.lock
ct lint --all --config tests/charts/config/ct.yaml
# Helm dependencies build and lint is done by `ct lint` command
rm -rf ${CHART_PATH}/../*.tgz
helm package ${CHART_PATH} --version ${VERSION} --destination ${CHART_PATH}/..

if [ "${SET_VERSION}" = "true" ]; then
ADD_VERSION="--version ${VERSION}"
else
ADD_VERSION=""
fi

helm package ${CHART_PATH} ${ADD_VERSION} --destination ${CHART_PATH}/..

readlink -f ${CHART_PATH}/../*.tgz > /tmp/selenium_chart_version
cat /tmp/selenium_chart_version
Expand Down
22 changes: 22 additions & 0 deletions tests/charts/make/chart_release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
set -x

NAMESPACE=${NAMESPACE:-"selenium"}
# Function to be executed on command failure
on_failure() {
local exit_status=$?
echo "There is step failed with exit status $exit_status"
exit $exit_status
}

# Trap ERR signal and call on_failure function
trap 'on_failure' ERR

CHART_PACKAGE_PATH=$(cat /tmp/selenium_chart_version)
if [ -z "${CHART_PACKAGE_PATH}" ] || [ ! -f "${CHART_PACKAGE_PATH}" ]; then
echo "Chart package path is empty. Please trigger chart_build.sh before this script."
exit 1
fi

echo "Pushing chart package to the registry"
helm push ${CHART_PACKAGE_PATH} oci://registry-1.docker.io/${NAMESPACE}

0 comments on commit 0bb07ef

Please sign in to comment.