mirror of
https://github.com/pi-hole/docker-pi-hole.git
synced 2025-12-19 18:08:35 +00:00
Simplify build and publish action for v6. No need to have an additional matrix for each registry
Remove un-needed action file Signed-off-by: Adam Warner <me@adamwarner.co.uk>
This commit is contained in:
48
.github/actions/merge-and-push/action.yml
vendored
48
.github/actions/merge-and-push/action.yml
vendored
@@ -1,48 +0,0 @@
|
||||
name: Merge and push
|
||||
description: Apply meta, create manifest, and push to container registry
|
||||
|
||||
inputs:
|
||||
imagename:
|
||||
required: true
|
||||
description: The name of the image to push
|
||||
platform:
|
||||
required: true
|
||||
description: The platform to push the image for
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
-
|
||||
name: Docker meta
|
||||
id: meta_docker
|
||||
uses: docker/metadata-action@v4
|
||||
with:
|
||||
images: |
|
||||
${{ inputs.imagename }},enable=${{ github.event_name != 'pull_request' && github.event_name != 'workflow_dispatch' }}
|
||||
foo/bar,enable=${{ github.event_name == 'pull_request' }}
|
||||
# We want to tag the image with the latest tag if the workflow was triggered by a tag
|
||||
flavor: |
|
||||
latest=${{ startsWith(github.ref, 'refs/tags/') }}
|
||||
# tags:
|
||||
# type=schedule means that a tag is applied when the workflow is triggered by a schedule event
|
||||
# type=ref,event=branch means that a tag is applied when the workflow is triggered by a push to a branch
|
||||
# type=ref,event=tag means that a tag is applied when the workflow is triggered by a push to a tag
|
||||
tags: |
|
||||
type=schedule,suffix=-${{ inputs.platform }},enable=${{ github.event_name == 'schedule' }}
|
||||
type=ref,event=branch,suffix=-${{ inputs.platform }},enable=${{ github.event_name != 'schedule' }}
|
||||
type=ref,event=tag,suffix=-${{ inputs.platform }}
|
||||
-
|
||||
name: Create manifest list and push to repository
|
||||
working-directory: /tmp/digests/dockerhub/${{ inputs.platform }}
|
||||
# When using composite actions, you have to specify the shell. As you
|
||||
# don’t specify a runner type in composite actions, you need to specify
|
||||
# the shell instead for each action.
|
||||
shell: bash
|
||||
run: |
|
||||
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
|
||||
$(printf '${{ inputs.imagename }}@sha256:%s ' *)
|
||||
-
|
||||
name: Inspect image
|
||||
shell: bash
|
||||
run: |
|
||||
docker buildx imagetools inspect ${{ inputs.imagename }}:${{ steps.meta_docker.outputs.version }}
|
||||
70
.github/workflows/build-and-publish.yml
vendored
70
.github/workflows/build-and-publish.yml
vendored
@@ -16,16 +16,12 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
registry: [dockerhub, ghcr]
|
||||
platform: [linux/amd64, linux/386, linux/arm/v6, linux/arm/v7, linux/arm64]
|
||||
alpine_version: [3.19]
|
||||
include:
|
||||
- registry: dockerhub
|
||||
platform: linux/riscv64
|
||||
alpine_version: edge
|
||||
- registry: ghcr
|
||||
platform: linux/riscv64
|
||||
- platform: linux/riscv64
|
||||
alpine_version: edge
|
||||
|
||||
steps:
|
||||
- name: Prepare name for digest up/download
|
||||
run: |
|
||||
@@ -35,13 +31,14 @@ jobs:
|
||||
- name: Checkout Repo
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Docker meta (Docker Hub and GitHub Container Registry)
|
||||
- name: Docker meta
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
images: |
|
||||
${{ env[matrix.registry] }}
|
||||
${{ env.dockerhub }}
|
||||
${{ env.ghcr }}
|
||||
flavor: |
|
||||
latest=false
|
||||
tags: |
|
||||
@@ -59,10 +56,11 @@ jobs:
|
||||
uses: docker/setup-qemu-action@v3
|
||||
with:
|
||||
platforms: ${{ matrix.platform}}
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Build container and push by digest (${{ matrix.registry }})
|
||||
- name: Build container and push by digest
|
||||
id: build
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
@@ -73,18 +71,18 @@ jobs:
|
||||
alpine_version=${{ matrix.alpine_version }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
outputs: |
|
||||
type=image,name=${{ env[matrix.registry] }},push-by-digest=true,name-canonical=true,push=true
|
||||
type=image,name=${{ env.dockerhub }},push-by-digest=true,name-canonical=true,push=true
|
||||
|
||||
- name: Export digests
|
||||
run: |
|
||||
mkdir -p /tmp/digests/${{ matrix.registry }}
|
||||
mkdir -p /tmp/digests
|
||||
digest_docker="${{ steps.build.outputs.digest }}"
|
||||
touch "/tmp/digests/${{ matrix.registry }}/${digest_docker#sha256:}"
|
||||
touch "/tmp/digests/${digest_docker#sha256:}"
|
||||
|
||||
- name: Upload digest
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: digests-${{ matrix.registry }}-${{ env.PLATFORM_PAIR }}
|
||||
name: digests-${{ env.PLATFORM_PAIR }}
|
||||
path: /tmp/digests/*
|
||||
if-no-files-found: error
|
||||
retention-days: 1
|
||||
@@ -93,10 +91,6 @@ jobs:
|
||||
# If we would push immediately above, the individual runners would overwrite each other's images
|
||||
# https://docs.docker.com/build/ci/github-actions/multi-platform/#distribute-build-across-multiple-runners
|
||||
merge-and-deploy:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
registry: [dockerhub, ghcr]
|
||||
runs-on: ubuntu-latest
|
||||
needs:
|
||||
- build
|
||||
@@ -107,13 +101,26 @@ jobs:
|
||||
- name: Download digests
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
path: /tmp/digests/${{ matrix.registry }}
|
||||
pattern: digests-${{ matrix.registry }}-*
|
||||
path: /tmp/digests
|
||||
pattern: digests-*
|
||||
merge-multiple: true
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Docker meta
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
images: |
|
||||
${{ env.dockerhub }}
|
||||
${{ env.ghcr }}
|
||||
flavor: |
|
||||
latest=false
|
||||
tags: |
|
||||
development-v6
|
||||
|
||||
- name: Login to DockerHub and GitHub Container Registry
|
||||
uses: ./.github/actions/login-repo
|
||||
with:
|
||||
@@ -122,24 +129,15 @@ jobs:
|
||||
ghcr_username: ${{ github.repository_owner }}
|
||||
ghcr_password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Docker meta (Docker Hub and GitHub Container Registry)
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
images: |
|
||||
${{ env[matrix.registry] }}
|
||||
flavor: |
|
||||
latest=false
|
||||
tags: |
|
||||
development-v6
|
||||
|
||||
- name: Create manifest list and push (${{ matrix.registry }})
|
||||
working-directory: /tmp/digests/${{ matrix.registry }}
|
||||
- name: Create manifest list and push (DockerHub and GitHub Container Registry)
|
||||
working-directory: /tmp/digests
|
||||
run: |
|
||||
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
|
||||
$(printf '${{ env[matrix.registry] }}@sha256:%s ' *)
|
||||
$(printf '${{ env.dockerhub }}@sha256:%s ' *)
|
||||
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
|
||||
$(printf '${{ env.ghcr }}@sha256:%s ' *)
|
||||
|
||||
- name: Inspect image
|
||||
- name: Inspect images
|
||||
run: |
|
||||
docker buildx imagetools inspect ${{ env[matrix.registry] }}:${{ steps.meta.outputs.version }}
|
||||
docker buildx imagetools inspect ${{ env.dockerhub }}:${{ steps.meta.outputs.version }}
|
||||
docker buildx imagetools inspect ${{ env.ghcr }}:${{ steps.meta.outputs.version }}
|
||||
Reference in New Issue
Block a user