diff --git a/.github/actions/version-checks/action.yml b/.github/actions/version-checks/action.yml new file mode 100644 index 0000000..e40ba6e --- /dev/null +++ b/.github/actions/version-checks/action.yml @@ -0,0 +1,21 @@ +name: Check Omada Version Availability +description: Check if the given Omada version is available +inputs: + version: + description: The version to check + required: true +runs: + using: "composite" + steps: + - name: Check Omada Version + shell: bash + run: | + URL="https://omada-controller-url.mbentley.net/hooks/omada_ver_to_url?omada-ver=${{ inputs.version }}" + OUTPUT=$(curl -sf "$URL") + if [ -z "$OUTPUT" ]; then + echo "Error: No output received from $URL" + exit 1 + else + echo "Success: Received output" + echo "$OUTPUT" + fi diff --git a/.github/workflows/docker-build.yaml b/.github/workflows/docker-build.yaml index dedc9e0..ba3ec66 100644 --- a/.github/workflows/docker-build.yaml +++ b/.github/workflows/docker-build.yaml @@ -27,6 +27,11 @@ jobs: echo "VERSION=$VERSION" >> $GITHUB_ENV echo "Docker Tag: $VERSION" + - name: Check Omada Version Availability + uses: ./.github/actions/version-checks + with: + version: "${{ env.VERSION }}" + - name: Build Docker Image run: | docker buildx build \ diff --git a/.github/workflows/docker-publish.yaml b/.github/workflows/docker-publish.yaml index 9010640..9ca0997 100644 --- a/.github/workflows/docker-publish.yaml +++ b/.github/workflows/docker-publish.yaml @@ -34,8 +34,7 @@ jobs: echo "$1" | awk '{print toupper(substr($0,1,1)) tolower(substr($0,2))}' } CAPITALIZED_TARGET=$(capitalize "${{ matrix.target }}") - CONFIG_FILE="Omada ${CAPITALIZED_TARGET}/config.yaml" - VERSION=$(yq '.version' "${CONFIG_FILE}") + VERSION=$(yq '.version' "Omada ${CAPITALIZED_TARGET}/config.yaml") DOCKER_IMAGE="${{ secrets.DOCKER_USER_NAME }}/home-assistant-omada" echo "VERSION=$VERSION" >> $GITHUB_ENV @@ -45,6 +44,11 @@ jobs: echo "Version: $VERSION" echo "Docker Image: $DOCKER_IMAGE" + - name: Check Omada Version Availability + uses: ./.github/actions/version-checks + with: + version: "${{ env.VERSION }}" + - name: Check if Image Exists id: check_image run: | @@ -54,15 +58,14 @@ jobs: echo "exists=false" >> $GITHUB_OUTPUT fi - - name: Build and Push Docker Image + - name: Build and push if: steps.check_image.outputs.exists == 'false' - run: | - docker buildx build \ - --platform linux/amd64,linux/arm64 \ - --file "./Omada Dev/Dockerfile" \ - --tag "${{ env.DOCKER_IMAGE }}-${{ matrix.target }}:${{ env.VERSION }}" \ - --push \ - --build-arg INSTALL_VER="${{ env.VERSION }}" \ - --cache-from "type=registry,ref=${{ env.DOCKER_IMAGE }}-${{ matrix.target }}:cache" \ - --cache-to "type=registry,ref=${{ env.DOCKER_IMAGE }}-${{ matrix.target }}:cache,mode=max" \ - "./Omada Dev" + uses: docker/build-push-action@v6 + with: + context: "Omada\ Dev" + build-args: INSTALL_VER=${{ env.VERSION }} + platforms: linux/amd64,linux/arm64 + push: true + tags: "${{ env.DOCKER_IMAGE }}-${{ matrix.target }}:${{ env.VERSION }}" + cache-from: type=registry,ref=${{ env.DOCKER_IMAGE }}-${{ matrix.target }}:cache + cache-to: type=registry,ref=${{ env.DOCKER_IMAGE }}-${{ matrix.target }}:cache,mode=max