55 lines
1.6 KiB
YAML
55 lines
1.6 KiB
YAML
name: 'Docker Build and Push'
|
|
description: 'Extracts metadata and builds/pushes a Docker image'
|
|
|
|
inputs:
|
|
registry_image:
|
|
description: 'The registry and image name to tag (e.g., ghcr.io/user/repo)'
|
|
required: true
|
|
file:
|
|
description: 'Path to the Dockerfile'
|
|
required: false
|
|
default: 'Dockerfile'
|
|
platforms:
|
|
description: 'Comma-separated list of platforms to build for'
|
|
required: false
|
|
default: 'linux/amd64'
|
|
context:
|
|
description: 'Build context path'
|
|
required: false
|
|
default: '.'
|
|
push:
|
|
description: 'Whether to push the image'
|
|
required: false
|
|
default: 'true'
|
|
outputs:
|
|
description: 'Custom outputs configuration'
|
|
required: false
|
|
|
|
runs:
|
|
using: "composite"
|
|
steps:
|
|
- name: Extract metadata (tags, labels) for Docker
|
|
id: meta
|
|
uses: docker/metadata-action@v6
|
|
with:
|
|
context: workflow
|
|
images: ${{ inputs.registry_image }}
|
|
tags: |
|
|
type=ref,event=branch
|
|
type=ref,event=tag
|
|
type=ref,event=pr
|
|
type=semver,pattern={{version}}
|
|
type=semver,pattern={{major}}.{{minor}}
|
|
type=raw,value=latest,enable={{is_default_branch}}
|
|
|
|
- name: Build and push Docker image
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: ${{ inputs.context }}
|
|
file: ${{ inputs.file }}
|
|
platforms: ${{ inputs.platforms }}
|
|
push: ${{ inputs.outputs == '' && inputs.push == 'true' || false }}
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
outputs: ${{ inputs.outputs }}
|