2024-08-16 18:56:41 +00:00
|
|
|
name: "Docker build"
|
|
|
|
description: "Builds a docker image"
|
|
|
|
inputs:
|
|
|
|
name:
|
|
|
|
description: "Directory name"
|
|
|
|
required: true
|
2024-08-16 19:06:25 +00:00
|
|
|
REGISTRY_USERNAME:
|
|
|
|
description: "Registry username"
|
|
|
|
required: true
|
|
|
|
REGISTRY_TOKEN:
|
|
|
|
description: "Registry token"
|
|
|
|
required: true
|
|
|
|
DOCKER_USERNAME:
|
|
|
|
description: "Docker username"
|
|
|
|
required: true
|
|
|
|
DOCKER_PASSWORD:
|
|
|
|
description: "Docker password"
|
|
|
|
required: true
|
2024-08-16 18:56:41 +00:00
|
|
|
|
|
|
|
runs:
|
|
|
|
using: "composite"
|
|
|
|
steps:
|
|
|
|
- name: Checkout
|
2024-09-04 06:03:36 +00:00
|
|
|
uses: https://git.kjan.de/actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
|
2024-08-16 18:56:41 +00:00
|
|
|
|
|
|
|
- name: Set up Docker Buildx
|
2024-09-04 06:03:36 +00:00
|
|
|
uses: https://git.kjan.de/actions/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3
|
2024-08-16 18:56:41 +00:00
|
|
|
|
|
|
|
- name: Login to local Docker Registry
|
2024-09-04 06:03:36 +00:00
|
|
|
uses: https://git.kjan.de/actions/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3
|
2024-08-16 18:56:41 +00:00
|
|
|
with:
|
|
|
|
registry: git.kjan.de
|
2024-08-16 19:06:25 +00:00
|
|
|
username: ${{ inputs.REGISTRY_USERNAME }}
|
|
|
|
password: ${{ inputs.REGISTRY_TOKEN }}
|
2024-08-16 18:56:41 +00:00
|
|
|
|
|
|
|
- name: Login to Docker.io Registry
|
2024-09-04 06:03:36 +00:00
|
|
|
uses: https://git.kjan.de/actions/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3
|
2024-08-16 18:56:41 +00:00
|
|
|
with:
|
2024-08-16 19:06:25 +00:00
|
|
|
username: ${{ inputs.DOCKER_USERNAME }}
|
|
|
|
password: ${{ inputs.DOCKER_PASSWORD }}
|
2024-08-16 18:56:41 +00:00
|
|
|
|
|
|
|
- name: Cache Docker layers
|
2024-09-04 06:03:36 +00:00
|
|
|
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
|
2024-08-16 18:56:41 +00:00
|
|
|
with:
|
|
|
|
path: /tmp/.buildx-cache
|
|
|
|
key: ${{ runner.os }}-${{ inputs.name }}-${{ github.sha }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-${{ inputs.name }}-
|
|
|
|
|
|
|
|
- name: Build and push
|
2024-09-27 15:01:14 +00:00
|
|
|
uses: https://git.kjan.de/actions/build-push-action@32945a339266b759abcbdc89316275140b0fc960 # v6
|
2024-08-16 18:56:41 +00:00
|
|
|
with:
|
|
|
|
cache-from: type=local,src=/tmp/.buildx-cache
|
|
|
|
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
|
|
|
|
context: ./images/actions/${{ inputs.name }}
|
|
|
|
push: ${{ github.ref == 'refs/heads/main' }}
|
|
|
|
tags: |
|
|
|
|
git.kjan.de/actions/${{ inputs.name }}:latest
|
|
|
|
git.kjan.de/actions/${{ inputs.name }}:${{ gitea.sha }}
|
|
|
|
|
|
|
|
- # Temp fix
|
|
|
|
# https://github.com/docker/build-push-action/issues/252
|
|
|
|
# https://github.com/moby/buildkit/issues/1896
|
|
|
|
name: Move cache
|
|
|
|
run: |
|
|
|
|
rm -rf /tmp/.buildx-cache
|
|
|
|
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
|