ci: enable docker build & sha extraction on PRs
CI / CI (pull_request) Successful in 14m31s

- Get short SHA on all events (PRs + pushes)
- Registry login on all events
- Build Docker image on all events (validate Dockerfile on PRs)
- Push only on push/workflow_dispatch (not PRs)
- Prune images on all events

This ensures PR builds verify Docker image builds successfully
This commit is contained in:
2026-09-08 15:59:21 -07:00
parent 168fd41fd2
commit 88234ac927
-4
View File
@@ -36,12 +36,10 @@ jobs:
run: cargo clippy --all --all-targets -- -D warnings 2>&1 | tail -50 || true
- name: Get short SHA
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
id: sha
run: echo "short_sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Registry login
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
run: |
echo "${REGISTRY_TOKEN}" | docker login "${REGISTRY}" \
--username "${REGISTRY_USER}" --password-stdin
@@ -50,7 +48,6 @@ jobs:
REGISTRY_TOKEN: ${{ secrets.FORGEJO_REGISTRY_TOKEN }}
- name: Build Docker image
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
run: |
docker build --no-cache --progress=plain \
-t "${IMAGE}:${{ steps.sha.outputs.short_sha }}" \
@@ -65,5 +62,4 @@ jobs:
echo "✓ Pushed: ${IMAGE}:${{ steps.sha.outputs.short_sha }}"
- name: Prune unused images
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
run: docker image prune -a --force 2>&1 | tail -3 || true