Files
docker-build-action/action.yml
Renovate Bot 889cffd45b
All checks were successful
Actionlint / build (push) Successful in 7s
Update Github Actions #none minor
2025-02-26 16:07:06 +00:00

89 lines
4.0 KiB
YAML

name: 'Tag Build and Push Docker image'
description: 'Tags verion in current repo, builds docker image and pushes it to registry'
inputs:
registry: # id of input
description: 'docker regisry host name'
required: true
default: 'gitea.phadric.de'
image_name:
description: 'name of the dockerimage'
required: true
default: ${{ github.repository }}
token:
description: 'repo auth token'
required: true
runs:
using: "composite"
steps:
- run: echo "::group::Checkout repository"
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: '0'
- run: echo "::endgroup::"
- run: echo "::group::Bump version and push tag"
- name: Bump version and push tag
id: tag
uses: phadric/github-tag-action@a5250a59655e9f4b0350407380a92c73948f2aec # master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # if you don't want to set write permissions use a PAT token
DEFAULT_BUMP: patch
GIT_API_TAGGING: false # dont use API
WITH_V: true
PRERELEASE: true
PRERELEASE_SUFFIX: ${{ github.ref_name }}
- run: echo "::endgroup::"
- run: echo "::group::Extract Docker metadata"
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804 # v5.7.0
with:
flavor: |
latest=${{ github.ref_name == 'main' || github.ref_name == 'master' }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}},value=${{steps.tag.outputs.tag}}
# output 0.1
type=semver,pattern={{major}}.{{minor}},value=${{steps.tag.outputs.tag}}
# disabled if major zero
type=semver,pattern={{major}},value=${{steps.tag.outputs.tag}},enable=${{ !startsWith(steps.tag.outputs.tag, 'v0.') }}
images: ${{ inputs.registry }}/${{ inputs.image_name }}
- run: echo "::endgroup::"
- run: echo "::group::Configure build Cache"
- uses: int128/docker-build-cache-config-action@622932dfa73db7d3a65e40d5fcc094f2101e659a # v1.37.0
id: cache
with:
image: ${{ inputs.registry }}/${{ inputs.image_name }}-cache
extra-cache-to: image-manifest=true
- run: echo "::endgroup::"
- run: echo "::group::Setup Buildx"
- name: Setup Docker buildx
uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0
- run: echo "::endgroup::"
- run: echo "::group::Log into Registry ${{ inputs.registry }}"
- name: Log into registry ${{ inputs.registry }}
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: ${{ inputs.registry }}
username: ${{ github.actor }}
password: ${{ inputs.token }}
- run: echo "::endgroup::"
- run: echo "::group::Build and Push docker image"
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@471d1dc4e07e5cdedd4c2171150001c434f0b7a4 # v6.15.0
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
platforms: linux/amd64
labels: ${{ steps.meta.outputs.labels }}
cache-from: |
type=registry,ref=${{ inputs.registry }}/${{ inputs.image_name }}-cache:latest
type=registry,ref=${{ inputs.registry }}/${{ inputs.image_name }}-cache:${{ github.ref_name }}
${{ steps.cache.outputs.cache-from }}
cache-to: |
${{ steps.cache.outputs.cache-to }}
type=registry,ref=${{ inputs.registry }}/${{ inputs.image_name }}-cache:latest,mode=max,image-manifest=true
- run: echo "::endgroup::"