From eedbd78d61db7db9ecc7a87d2587b32f5cd52b4d Mon Sep 17 00:00:00 2001 From: kennyboy55 Date: Sat, 24 Jan 2026 14:33:42 +0100 Subject: [PATCH] Move check to separate job --- .gitea/workflows/timelimit-server-ui.yml | 47 ++++++++++++------------ 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/.gitea/workflows/timelimit-server-ui.yml b/.gitea/workflows/timelimit-server-ui.yml index 256522f..b87dcfe 100644 --- a/.gitea/workflows/timelimit-server-ui.yml +++ b/.gitea/workflows/timelimit-server-ui.yml @@ -6,14 +6,12 @@ on: workflow_dispatch: jobs: - build: + check: runs-on: ubuntu-latest - + outputs: + exists: ${{ steps.exists.outputs.exists }} + sha: ${{ steps.sha.outputs.sha }} steps: - # Checkout THIS repository (Dockerfile lives here) - - name: Checkout current repository - uses: actions/checkout@v4 - # Get latest timelimit-server-ui commit SHA - name: Get timelimit-server-ui commit SHA id: sha @@ -21,13 +19,6 @@ jobs: SHA=$(git ls-remote https://gitea.furb.it/${{ vars.FRONTEND_PATH }}.git refs/heads/${{ vars.FRONTEND_BRANCH }} | cut -f1) echo "sha=$SHA" >> $GITEA_OUTPUT - # Login to registry (needed to inspect latest image) - - name: Docker login - run: | - echo "${{ secrets.ACCESS_TOKEN }}" | docker login gitea.furb.it \ - -u "${{ secrets.USERNAME }}" \ - --password-stdin - # Try to read timelimit-server-ui SHA from latest image label - name: Check if image with timelimit-server-ui SHA exists id: exists @@ -45,20 +36,21 @@ jobs: echo "exists=false" >> $GITEA_OUTPUT fi - # Exit early if unchanged - - name: Skip build if image already exists - run: | - if [ "${{ steps.exists.outputs.exists }}" = "true" ]; then - echo "Image for this timelimit-server-ui commit already exists. Skipping build." - exit 0 - fi + build: + runs-on: ubuntu-latest + needs: check + if: needs.check.outputs.exists == 'false' + steps: + # Checkout THIS repository (Dockerfile lives here) + - name: Checkout current repository + uses: actions/checkout@v4 # Checkout timelimit-server-ui repository for build - name: Checkout timelimit-server-ui repository uses: actions/checkout@v4 with: repository: ${{ vars.FRONTEND_PATH }}.git - ref: ${{ steps.sha.outputs.sha }} + ref: ${{ needs.check.outputs.sha }} path: timelimit-server-ui token: ${{ secrets.ACCESS_TOKEN }} @@ -84,18 +76,25 @@ jobs: rm -rf dist cp -r timelimit-server-ui/dist ./dist + # Login to registry (needed to inspect latest image) + - name: Docker login + run: | + echo "${{ secrets.ACCESS_TOKEN }}" | docker login gitea.furb.it \ + -u "${{ secrets.USERNAME }}" \ + --password-stdin + # Build image with commit-SHA tag and label - name: Build Docker image run: | docker build \ -f Dockerfile-ui \ - --label timelimit-server-ui.sha=${{ steps.sha.outputs.sha }} \ - -t gitea.furb.it/${{ vars.FRONTEND_IMAGE }}:${{ steps.sha.outputs.sha }} \ + --label timelimit-server-ui.sha=${{ needs.check.outputs.sha }} \ + -t gitea.furb.it/${{ vars.FRONTEND_IMAGE }}:${{ needs.check.outputs.sha }} \ -t gitea.furb.it/${{ vars.FRONTEND_IMAGE }}:latest \ . # Push images - name: Push Docker images run: | - docker push gitea.furb.it/${{ vars.FRONTEND_IMAGE }}:${{ steps.sha.outputs.sha }} + docker push gitea.furb.it/${{ vars.FRONTEND_IMAGE }}:${{ needs.check.outputs.sha }} docker push gitea.furb.it/${{ vars.FRONTEND_IMAGE }}:latest