add docker-build composite action (fixes runner caching)
This commit is contained in:
parent
76fa4ea95b
commit
993c51b6ee
1 changed files with 53 additions and 0 deletions
53
docker-build/action.yml
Normal file
53
docker-build/action.yml
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
name: Docker Build and Push
|
||||
description: Build and push Docker image to Forgejo registry
|
||||
|
||||
inputs:
|
||||
image_name:
|
||||
required: true
|
||||
description: Docker image name (e.g. org/repo)
|
||||
context:
|
||||
default: "."
|
||||
description: Build context path
|
||||
dockerfile:
|
||||
default: "./Dockerfile"
|
||||
description: Dockerfile path
|
||||
registry_auth:
|
||||
required: true
|
||||
description: Base64-encoded registry credentials (user:token)
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
with:
|
||||
driver: docker
|
||||
|
||||
- name: Configure registry auth
|
||||
if: github.event_name != 'pull_request'
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir -p ~/.docker
|
||||
printf '{"auths":{"git.vodyanoysh.ru":{"auth":"%s"}}}' "${{ inputs.registry_auth }}" > ~/.docker/config.json
|
||||
|
||||
- name: Extract metadata
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: git.vodyanoysh.ru/${{ inputs.image_name }}
|
||||
flavor: |
|
||||
latest=true
|
||||
tags: |
|
||||
type=ref,event=branch
|
||||
type=ref,event=pr
|
||||
type=semver,pattern={{version}}
|
||||
type=sha,prefix=sha-
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: ${{ inputs.context }}
|
||||
file: ${{ inputs.dockerfile }}
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
Loading…
Reference in a new issue