diff --git a/.github/workflows/publish-containers.yml b/.github/workflows/publish-containers.yml index 329bc7c..09761a0 100644 --- a/.github/workflows/publish-containers.yml +++ b/.github/workflows/publish-containers.yml @@ -19,7 +19,6 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 - fetch-tags: true - name: Checkout workflow_run commit and refresh tags run: | @@ -35,22 +34,30 @@ jobs: SHA="$(git rev-parse HEAD)" V_TAG="$(git tag --points-at "${SHA}" --list 'v*' | sort -V | tail -n1)" - [[ -n "$V_TAG" ]] || { echo "No version tag found"; exit 1; } + if [[ -z "${V_TAG}" ]]; then + echo "No version tag found for ${SHA}. Skipping publish." + echo "should_publish=false" >> "$GITHUB_OUTPUT" + exit 0 + fi + VERSION="${V_TAG#v}" STABLE_SHA="$(git rev-parse -q --verify refs/tags/stable^{commit} 2>/dev/null || true)" IS_STABLE=false [[ -n "${STABLE_SHA}" && "${STABLE_SHA}" == "${SHA}" ]] && IS_STABLE=true + echo "should_publish=true" >> "$GITHUB_OUTPUT" echo "version=${VERSION}" >> "$GITHUB_OUTPUT" echo "is_stable=${IS_STABLE}" >> "$GITHUB_OUTPUT" - name: Set up Docker Buildx + if: ${{ steps.info.outputs.should_publish == 'true' }} uses: docker/setup-buildx-action@v3 with: use: true - name: Login to GHCR + if: ${{ steps.info.outputs.should_publish == 'true' }} uses: docker/login-action@v3 with: registry: ghcr.io @@ -58,6 +65,7 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: Publish all images + if: ${{ steps.info.outputs.should_publish == 'true' }} run: | set -euo pipefail OWNER="${{ github.repository_owner }}" \