From e220b5a0c2a889ff7c9d753c21444f59e8067365 Mon Sep 17 00:00:00 2001 From: Saman Sajedi Date: Sat, 15 Aug 2026 13:13:50 +0330 Subject: [PATCH] fixed runner dependency issue --- .gitea/workflows/build-and-push.yml | 46 ++++++++++++++++++++++------- mqtt-cert-manager/config.yaml | 2 +- 2 files changed, 36 insertions(+), 12 deletions(-) diff --git a/.gitea/workflows/build-and-push.yml b/.gitea/workflows/build-and-push.yml index 11a27e0..2476760 100644 --- a/.gitea/workflows/build-and-push.yml +++ b/.gitea/workflows/build-and-push.yml @@ -16,16 +16,15 @@ # release — Supervisor pulls the image tag matching that version # exactly, so an unbumped version means it silently keeps using the # old image. +# +# Triggers only on pushed tags matching "v*", and only builds if that +# tag's commit is actually part of main's history (see check-branch job). name: build-and-push on: push: tags: - "v*" - # paths: - # - "mqtt-cert-manager/**" - # branches: - # - main env: REGISTRY_HOST: git.example.com @@ -33,7 +32,32 @@ env: IMAGE_NAME: mqtt-cert-manager jobs: + check-branch: + runs-on: ubuntu-latest + outputs: + on_main: ${{ steps.check.outputs.on_main }} + steps: + - name: Checkout (full history) + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Make sure we have main's history too + run: git fetch origin main:refs/remotes/origin/main + + - name: Is this tag's commit part of main? + id: check + run: | + if git merge-base --is-ancestor HEAD origin/main; then + echo "on_main=true" >> "$GITHUB_OUTPUT" + else + echo "on_main=false" >> "$GITHUB_OUTPUT" + echo "Tag $GITHUB_REF_NAME points to a commit that is not on main — skipping build." + fi + build: + needs: check-branch + if: needs.check-branch.outputs.on_main == 'true' runs-on: ubuntu-latest strategy: matrix: @@ -56,18 +80,18 @@ jobs: - name: Read add-on version id: version + # Plain shell instead of python3+PyYAML: the runner's Python has + # no yaml module installed, and this value is a simple one-liner + # anyway (version: "0.1.0"), so there's no need for a real YAML + # parser or an extra apt/pip install step just for this. run: | - VERSION=$(python3 -c "import yaml; print(yaml.safe_load(open('mqtt-cert-manager/config.yaml'))['version'])") + VERSION=$(grep '^version:' mqtt-cert-manager/config.yaml | cut -d'"' -f2) echo "version=$VERSION" >> "$GITHUB_OUTPUT" - name: Read base image for this arch from build.yaml id: base run: | - BUILD_FROM=$(python3 -c " - import yaml - d = yaml.safe_load(open('mqtt-cert-manager/build.yaml')) - print(d['build_from']['${{ matrix.arch }}']) - ") + BUILD_FROM=$(grep -E "^[[:space:]]*${{ matrix.arch }}:" mqtt-cert-manager/build.yaml | cut -d'"' -f2) echo "build_from=$BUILD_FROM" >> "$GITHUB_OUTPUT" - name: Set up QEMU (needed to build non-amd64 targets on an amd64 runner) @@ -93,4 +117,4 @@ jobs: BUILD_FROM=${{ steps.base.outputs.build_from }} tags: | ${{ env.REGISTRY_HOST }}/${{ env.REGISTRY_OWNER }}/${{ env.IMAGE_NAME }}-${{ matrix.arch }}:${{ steps.version.outputs.version }} - ${{ env.REGISTRY_HOST }}/${{ env.REGISTRY_OWNER }}/${{ env.IMAGE_NAME }}-${{ matrix.arch }}:latest + ${{ env.REGISTRY_HOST }}/${{ env.REGISTRY_OWNER }}/${{ env.IMAGE_NAME }}-${{ matrix.arch }}:latest \ No newline at end of file diff --git a/mqtt-cert-manager/config.yaml b/mqtt-cert-manager/config.yaml index a70e0ef..a2bb895 100644 --- a/mqtt-cert-manager/config.yaml +++ b/mqtt-cert-manager/config.yaml @@ -1,5 +1,5 @@ name: "MQTT Certificate Manager" -version: "0.3.1" +version: "0.3.2" slug: "mqtt_cert_manager" description: "Local CA that issues and manages TLS client certificates for MQTT nodes" url: "https://gitea.viratak.com/eta/mqtt-cert-manager"