From 989ad3fbfba6919c7c696610de1fd1bea6d232c0 Mon Sep 17 00:00:00 2001 From: Patrick de Ruiter Date: Fri, 26 Dec 2025 02:00:35 +0100 Subject: [PATCH] fix: run push job in same workflow after autotag Gitea doesn't trigger new workflows when tags are pushed by the workflow itself. Modified push job to: - Depend on autotag job - Use autotag outputs for version when not triggered by tag ref - Run when autotag succeeds OR when triggered by tag push --- .gitea/workflows/build.yaml | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml index a73d5db..e30cc2b 100644 --- a/.gitea/workflows/build.yaml +++ b/.gitea/workflows/build.yaml @@ -205,11 +205,17 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # Stage 6: Push to registry (only on tags) + # Stage 6: Push to registry + # Runs after autotag (on main) or after tests (on tag push) push: runs-on: ubuntu-latest - needs: [test, security-scan] - if: startsWith(github.ref, 'refs/tags/v') + needs: [test, security-scan, autotag] + if: | + always() && + needs.test.result == 'success' && + needs.security-scan.result == 'success' && + github.event_name == 'push' && + (needs.autotag.result == 'success' || startsWith(github.ref, 'refs/tags/v')) outputs: version: ${{ steps.version.outputs.VERSION }} full_image: ${{ steps.version.outputs.FULL_IMAGE }} @@ -227,7 +233,19 @@ jobs: - name: Determine version and tags id: version run: | - VERSION="${GITHUB_REF#refs/tags/v}" + # Get version from autotag output or from git ref + if [[ "$GITHUB_REF" == refs/tags/v* ]]; then + VERSION="${GITHUB_REF#refs/tags/v}" + else + # Use version from autotag job + VERSION="${{ needs.autotag.outputs.version }}" + fi + + if [ -z "$VERSION" ]; then + echo "::error::No version determined" + exit 1 + fi + # For releases, tag with version, major.minor, and latest MAJOR=$(echo $VERSION | cut -d. -f1) MINOR=$(echo $VERSION | cut -d. -f2) @@ -236,6 +254,7 @@ jobs: echo "VERSION=$VERSION" >> $GITHUB_OUTPUT echo "TAGS=$TAGS" >> $GITHUB_OUTPUT echo "FULL_IMAGE=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${VERSION}" >> $GITHUB_OUTPUT + echo "Pushing version: $VERSION" - name: Log in to Docker Registry run: | @@ -258,7 +277,7 @@ jobs: update-cd: runs-on: ubuntu-latest needs: push - if: startsWith(github.ref, 'refs/tags/v') + if: needs.push.result == 'success' steps: - name: Trigger CD pipeline run: |