Move check to separate job

This commit is contained in:
2026-01-24 14:33:42 +01:00
parent 7e669b522f
commit eedbd78d61
+23 -24
View File
@@ -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