blumeops/.forgejo/actions/build-push-image/action.yaml
Erich Blume aab19c97fe
All checks were successful
Build Container / build (push) Successful in 40s
Restore docker buildx build (#149)
## Summary
- Switch build action back to `docker buildx build` now that runner v2.5.1 (with `docker-buildx-plugin`) is deployed

## Test plan
- [ ] Merge and tag `nettest-v0.12.0` to verify buildx works end-to-end

Reviewed-on: https://forge.ops.eblu.me/eblume/blumeops/pulls/149
2026-02-10 21:21:19 -08:00

67 lines
2.4 KiB
YAML

name: 'Build and Push Image'
description: 'Build a container image with Docker and push to registry.ops.eblu.me using skopeo'
# Note: Uses skopeo for push because Docker 27's manifest format has compatibility
# issues with zot registry. Skopeo handles manifest conversion correctly.
inputs:
context:
description: 'Build context path'
required: true
dockerfile:
description: 'Dockerfile path (relative to context)'
required: false
default: 'Dockerfile'
image_name:
description: 'Image name (without registry, e.g. blumeops/devpi)'
required: true
version:
description: 'Version tag (e.g. v1.0.0)'
required: true
registry:
description: 'Registry URL'
required: false
default: 'registry.ops.eblu.me'
runs:
using: 'composite'
steps:
- name: Build image
shell: bash
run: |
echo "Building ${{ inputs.image_name }}:${{ inputs.version }}"
docker buildx build \
--tag ${{ inputs.image_name }}:${{ inputs.version }} \
--file ${{ inputs.context }}/${{ inputs.dockerfile }} \
${{ inputs.context }}
- name: Push to registry
shell: bash
run: |
echo "Saving image to tarball..."
docker save ${{ inputs.image_name }}:${{ inputs.version }} -o /tmp/image.tar
echo "Installing skopeo..."
apk add --no-cache skopeo >/dev/null 2>&1 || apt-get update && apt-get install -y skopeo >/dev/null 2>&1 || true
echo "Pushing ${{ inputs.registry }}/${{ inputs.image_name }}:${{ inputs.version }}"
skopeo copy \
docker-archive:/tmp/image.tar \
docker://${{ inputs.registry }}/${{ inputs.image_name }}:${{ inputs.version }}
echo "Pushing ${{ inputs.registry }}/${{ inputs.image_name }}:${{ github.sha }}"
skopeo copy \
docker-archive:/tmp/image.tar \
docker://${{ inputs.registry }}/${{ inputs.image_name }}:${{ github.sha }}
rm -f /tmp/image.tar
- name: Summary
shell: bash
run: |
echo "Built and pushed:"
echo " ${{ inputs.registry }}/${{ inputs.image_name }}:${{ inputs.version }}"
echo " ${{ inputs.registry }}/${{ inputs.image_name }}:${{ github.sha }}"
echo ""
echo "Registry tags:"
curl -sf "https://${{ inputs.registry }}/v2/${{ inputs.image_name }}/tags/list" | jq -r '.tags[]' 2>/dev/null | sort -V | tail -10 || true