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
This commit is contained in:
parent
ee7f6bc7d8
commit
989f036acd
@ -205,11 +205,17 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
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:
|
push:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [test, security-scan]
|
needs: [test, security-scan, autotag]
|
||||||
if: startsWith(github.ref, 'refs/tags/v')
|
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:
|
outputs:
|
||||||
version: ${{ steps.version.outputs.VERSION }}
|
version: ${{ steps.version.outputs.VERSION }}
|
||||||
full_image: ${{ steps.version.outputs.FULL_IMAGE }}
|
full_image: ${{ steps.version.outputs.FULL_IMAGE }}
|
||||||
@ -227,7 +233,19 @@ jobs:
|
|||||||
- name: Determine version and tags
|
- name: Determine version and tags
|
||||||
id: version
|
id: version
|
||||||
run: |
|
run: |
|
||||||
|
# Get version from autotag output or from git ref
|
||||||
|
if [[ "$GITHUB_REF" == refs/tags/v* ]]; then
|
||||||
VERSION="${GITHUB_REF#refs/tags/v}"
|
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
|
# For releases, tag with version, major.minor, and latest
|
||||||
MAJOR=$(echo $VERSION | cut -d. -f1)
|
MAJOR=$(echo $VERSION | cut -d. -f1)
|
||||||
MINOR=$(echo $VERSION | cut -d. -f2)
|
MINOR=$(echo $VERSION | cut -d. -f2)
|
||||||
@ -236,6 +254,7 @@ jobs:
|
|||||||
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
|
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
|
||||||
echo "TAGS=$TAGS" >> $GITHUB_OUTPUT
|
echo "TAGS=$TAGS" >> $GITHUB_OUTPUT
|
||||||
echo "FULL_IMAGE=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${VERSION}" >> $GITHUB_OUTPUT
|
echo "FULL_IMAGE=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${VERSION}" >> $GITHUB_OUTPUT
|
||||||
|
echo "Pushing version: $VERSION"
|
||||||
|
|
||||||
- name: Log in to Docker Registry
|
- name: Log in to Docker Registry
|
||||||
run: |
|
run: |
|
||||||
@ -258,7 +277,7 @@ jobs:
|
|||||||
update-cd:
|
update-cd:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: push
|
needs: push
|
||||||
if: startsWith(github.ref, 'refs/tags/v')
|
if: needs.push.result == 'success'
|
||||||
steps:
|
steps:
|
||||||
- name: Trigger CD pipeline
|
- name: Trigger CD pipeline
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user