From 6607c97812dde6b830b1a43c5ac036a6b081618a Mon Sep 17 00:00:00 2001 From: Origami Official <64251776+origamiofficial@users.noreply.github.com> Date: Sun, 3 Mar 2024 01:21:09 +0600 Subject: [PATCH] Add validate github version --- .github/workflows/build-and-push-dispatch.yaml | 9 +++++++++ .github/workflows/build-and-push-latest.yaml | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/.github/workflows/build-and-push-dispatch.yaml b/.github/workflows/build-and-push-dispatch.yaml index 0833b43..99d3213 100644 --- a/.github/workflows/build-and-push-dispatch.yaml +++ b/.github/workflows/build-and-push-dispatch.yaml @@ -37,8 +37,17 @@ jobs: if: inputs.BaseImageTag == 'latest' id: version_code_check_latest run: | + function validate_version() { + local version="$1" + if [[ ! "$version" =~ ^[0-9]{4}\.[0-9]{2}\.[0-9]{1}$ ]]; then + echo "Error invalid version format: $version" + exit 1 + fi + } + CHECK_VERSION_CODE=$(curl -s https://api.github.com/repos/pi-hole/docker-pi-hole/releases/latest | grep "name" | cut -d'"' -f 4 | tail -n 1) echo "New Version: $CHECK_VERSION_CODE" + validate_version "$CHECK_VERSION_CODE" echo VERSION_CODE=$CHECK_VERSION_CODE >> $GITHUB_OUTPUT - name: Version code [dev / development-v6] diff --git a/.github/workflows/build-and-push-latest.yaml b/.github/workflows/build-and-push-latest.yaml index e4c931d..0eb3181 100644 --- a/.github/workflows/build-and-push-latest.yaml +++ b/.github/workflows/build-and-push-latest.yaml @@ -63,8 +63,17 @@ jobs: name: Version code id: version_code_check run: | + function validate_version() { + local version="$1" + if [[ ! "$version" =~ ^[0-9]{4}\.[0-9]{2}\.[0-9]{1}$ ]]; then + echo "Error invalid version format: $version" + exit 1 + fi + } + CHECK_VERSION_CODE=$(curl -s https://api.github.com/repos/pi-hole/docker-pi-hole/releases/latest | grep "name" | cut -d'"' -f 4 | tail -n 1) echo "New Version: $CHECK_VERSION_CODE" + validate_version "$CHECK_VERSION_CODE" echo VERSION_CODE=$CHECK_VERSION_CODE >> $GITHUB_OUTPUT - name: Set up QEMU