From d263d8a534b78dc4ee98166ad884a079945773fa Mon Sep 17 00:00:00 2001 From: Jan Novak Date: Fri, 12 Jun 2026 19:52:02 +0200 Subject: [PATCH] fix(ci): pass Go image tag from build to gitops via artifact github.event.workflow_run.head_branch is not populated for tag pushes in Gitea Actions, causing the image tag to resolve to empty (-go suffix with no version). Fix: build-go uploads the full image reference as a one-line artifact; gitops-update downloads it via download-artifact@v4 with run-id from the workflow_run event. Co-Authored-By: Claude Opus 4.8 --- .gitea/workflows/build.yaml | 8 ++++++++ .gitea/workflows/gitops-update.yaml | 14 ++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml index 9b996ce..5141661 100644 --- a/.gitea/workflows/build.yaml +++ b/.gitea/workflows/build.yaml @@ -63,3 +63,11 @@ jobs: --build-arg BUILD_DATE=$(date -u +%Y-%m-%dT%H:%M:%SZ) \ -t $IMAGE go/ docker push $IMAGE + echo "$IMAGE" > /tmp/go-image-tag.txt + + - name: Upload Go image tag for gitops workflow + uses: actions/upload-artifact@v4 + with: + name: go-image-tag + path: /tmp/go-image-tag.txt + retention-days: 1 diff --git a/.gitea/workflows/gitops-update.yaml b/.gitea/workflows/gitops-update.yaml index 9080bc0..9b49c86 100644 --- a/.gitea/workflows/gitops-update.yaml +++ b/.gitea/workflows/gitops-update.yaml @@ -58,16 +58,22 @@ jobs: -o /usr/local/bin/uh-cli chmod +x /usr/local/bin/uh-cli + - name: Download image tag artifact (workflow_run trigger) + if: github.event_name == 'workflow_run' + uses: actions/download-artifact@v4 + with: + name: go-image-tag + run-id: ${{ github.event.workflow_run.id }} + github-token: ${{ secrets.GITHUB_TOKEN }} + - name: Resolve image tag id: resolve run: | if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then - GIT_TAG="${{ inputs.tag }}" + IMAGE="gitea.home.hrajfrisbee.cz/${{ github.repository }}:${{ inputs.tag }}-go" else - # workflow_run: use the ref name of the triggering workflow (the pushed git tag). - GIT_TAG="${{ github.event.workflow_run.head_branch }}" + IMAGE="$(cat go-image-tag.txt)" fi - IMAGE="gitea.home.hrajfrisbee.cz/${{ github.repository }}:${GIT_TAG}-go" echo "image=${IMAGE}" >> "$GITHUB_OUTPUT" echo "Resolved image: ${IMAGE}" -- 2.49.1