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