Files
actions/docker-build/action.yaml
Hugo Nijhuis 14d7cae864 Add reusable Forgejo Actions
Composite actions for CI/CD workflows:
- checkout: Clone repo with configurable depth
- docker-build: Build Docker images with multiple tags
- docker-push: Push to Forgejo Packages registry
- create-tag: Auto-increment semantic version tags
- create-issue: Create issues via Forgejo API
- create-pr: Create pull requests via Forgejo API
- comment-pr: Add comments to PRs via Forgejo API

All actions use shell scripts (no Node.js required).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-31 00:30:07 +01:00

63 lines
1.6 KiB
YAML

name: Docker Build
description: Build a Docker image with tags
inputs:
image:
description: Full image name (registry/org/name)
required: true
tags:
description: Comma-separated list of tags
default: 'latest'
context:
description: Build context path
default: '.'
dockerfile:
description: Path to Dockerfile
default: 'Dockerfile'
build-args:
description: Build arguments (KEY=value, newline-separated)
default: ''
outputs:
images:
description: Built image references
value: ${{ steps.build.outputs.images }}
runs:
using: composite
steps:
- id: build
shell: bash
run: |
IMAGE="${{ inputs.image }}"
TAGS="${{ inputs.tags }}"
CONTEXT="${{ inputs.context }}"
DOCKERFILE="${{ inputs.dockerfile }}"
BUILD_ARGS="${{ inputs.build-args }}"
# Build tag arguments
TAG_ARGS=""
IMAGES=""
IFS=',' read -ra TAG_ARRAY <<< "$TAGS"
for tag in "${TAG_ARRAY[@]}"; do
tag=$(echo "$tag" | xargs) # trim whitespace
TAG_ARGS="$TAG_ARGS -t $IMAGE:$tag"
IMAGES="$IMAGES$IMAGE:$tag,"
done
IMAGES="${IMAGES%,}" # remove trailing comma
# Build build-arg arguments
BUILD_ARG_ARGS=""
if [ -n "$BUILD_ARGS" ]; then
while IFS= read -r arg; do
if [ -n "$arg" ]; then
BUILD_ARG_ARGS="$BUILD_ARG_ARGS --build-arg $arg"
fi
done <<< "$BUILD_ARGS"
fi
# Build the image
docker build $TAG_ARGS $BUILD_ARG_ARGS -f "$DOCKERFILE" "$CONTEXT"
echo "images=$IMAGES" >> $GITHUB_OUTPUT