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: workflow_dispatch:
jobs: jobs:
build: check:
runs-on: ubuntu-latest runs-on: ubuntu-latest
outputs:
exists: ${{ steps.exists.outputs.exists }}
sha: ${{ steps.sha.outputs.sha }}
steps: steps:
# Checkout THIS repository (Dockerfile lives here)
- name: Checkout current repository
uses: actions/checkout@v4
# Get latest timelimit-server-ui commit SHA # Get latest timelimit-server-ui commit SHA
- name: Get timelimit-server-ui commit SHA - name: Get timelimit-server-ui commit SHA
id: 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) SHA=$(git ls-remote https://gitea.furb.it/${{ vars.FRONTEND_PATH }}.git refs/heads/${{ vars.FRONTEND_BRANCH }} | cut -f1)
echo "sha=$SHA" >> $GITEA_OUTPUT 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 # Try to read timelimit-server-ui SHA from latest image label
- name: Check if image with timelimit-server-ui SHA exists - name: Check if image with timelimit-server-ui SHA exists
id: exists id: exists
@@ -45,20 +36,21 @@ jobs:
echo "exists=false" >> $GITEA_OUTPUT echo "exists=false" >> $GITEA_OUTPUT
fi fi
# Exit early if unchanged build:
- name: Skip build if image already exists runs-on: ubuntu-latest
run: | needs: check
if [ "${{ steps.exists.outputs.exists }}" = "true" ]; then if: needs.check.outputs.exists == 'false'
echo "Image for this timelimit-server-ui commit already exists. Skipping build." steps:
exit 0 # Checkout THIS repository (Dockerfile lives here)
fi - name: Checkout current repository
uses: actions/checkout@v4
# Checkout timelimit-server-ui repository for build # Checkout timelimit-server-ui repository for build
- name: Checkout timelimit-server-ui repository - name: Checkout timelimit-server-ui repository
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
repository: ${{ vars.FRONTEND_PATH }}.git repository: ${{ vars.FRONTEND_PATH }}.git
ref: ${{ steps.sha.outputs.sha }} ref: ${{ needs.check.outputs.sha }}
path: timelimit-server-ui path: timelimit-server-ui
token: ${{ secrets.ACCESS_TOKEN }} token: ${{ secrets.ACCESS_TOKEN }}
@@ -84,18 +76,25 @@ jobs:
rm -rf dist rm -rf dist
cp -r timelimit-server-ui/dist ./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 # Build image with commit-SHA tag and label
- name: Build Docker image - name: Build Docker image
run: | run: |
docker build \ docker build \
-f Dockerfile-ui \ -f Dockerfile-ui \
--label timelimit-server-ui.sha=${{ steps.sha.outputs.sha }} \ --label timelimit-server-ui.sha=${{ needs.check.outputs.sha }} \
-t gitea.furb.it/${{ vars.FRONTEND_IMAGE }}:${{ steps.sha.outputs.sha }} \ -t gitea.furb.it/${{ vars.FRONTEND_IMAGE }}:${{ needs.check.outputs.sha }} \
-t gitea.furb.it/${{ vars.FRONTEND_IMAGE }}:latest \ -t gitea.furb.it/${{ vars.FRONTEND_IMAGE }}:latest \
. .
# Push images # Push images
- name: Push Docker images - name: Push Docker images
run: | 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 docker push gitea.furb.it/${{ vars.FRONTEND_IMAGE }}:latest