Skip to content

Commit

Permalink
Attempt to reduce code reuse in action
Browse files Browse the repository at this point in the history
Signed-off-by: Adam Warner <me@adamwarner.co.uk>
  • Loading branch information
PromoFaux committed Jul 3, 2023
1 parent 56e2db6 commit f14ab99
Showing 1 changed file with 24 additions and 46 deletions.
70 changes: 24 additions & 46 deletions .github/workflows/v6-alpine-play.yml
Expand Up @@ -16,17 +16,10 @@ jobs:
strategy:
fail-fast: false
matrix:
registry: [ DOCKER_REGISTRY_IMAGE, GITHUB_REGISTRY_IMAGE ]
platform: [ linux/amd64, linux/386, linux/arm/v6, linux/arm/v7, linux/arm64/v8, linux/riscv64]
container: [ alpine:3.18 ]
include:
- platform: linux/amd64
container: alpine:3.18
- platform: linux/386
container: alpine:3.18
- platform: linux/arm/v6
container: alpine:3.18
- platform: linux/arm/v7
container: alpine:3.18
- platform: linux/arm64/v8
container: alpine:3.18
- platform: linux/riscv64
container: alpine:edge
steps:
Expand All @@ -41,8 +34,7 @@ jobs:
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
images: |
${{ env.DOCKER_REGISTRY_IMAGE }}
${{ env.GITHUB_REGISTRY_IMAGE }}
${{ env[matrix.registry] }}
flavor: |
latest=false
tags: |
Expand All @@ -66,7 +58,7 @@ jobs:
uses: docker/setup-buildx-action@v2

- name: Build container and push by digest (Docker Hub)
id: build_docker
id: build
uses: docker/build-push-action@v3
with:
context: ./src/
Expand All @@ -77,30 +69,13 @@ jobs:
push: true
labels: ${{ steps.meta.outputs.labels }}
outputs: |
type=image,name=${{ env.DOCKER_REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
- name: Build container and push by digest (GitHub Container Registry)
id: build_ghcr
uses: docker/build-push-action@v3
with:
context: ./src/
platforms: ${{ matrix.platform }}
build-args: |
PIHOLE_DOCKER_TAG=${{ steps.meta.outputs.version }}
CONTAINER=${{ matrix.container }}
push: true
labels: ${{ steps.meta.outputs.labels }}
outputs: |
type=image,name=${{ env.GITHUB_REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
type=image,name=${{ env[matrix.registry] }},push-by-digest=true,name-canonical=true,push=true
- name: Export digests
run: |
mkdir -p /tmp/digests/dockerhub/${{ env.context }}
mkdir -p /tmp/digests/ghcr/${{ env.context }}
digest_docker="${{ steps.build_docker.outputs.digest }}"
touch "/tmp/digests/dockerhub/${{ env.context }}/${digest_docker#sha256:}"
digest_ghcr="${{ steps.build_ghcr.outputs.digest }}"
touch "/tmp/digests/ghcr/${{ env.context }}/${digest_ghcr#sha256:}"
mkdir -p /tmp/digests/${{ matrix.registry }}
digest_docker="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${{matrix.registry}}/${digest_docker#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v3
Expand All @@ -117,6 +92,10 @@ jobs:
runs-on: ubuntu-latest
needs:
- build-and-test
strategy:
fail-fast: false
matrix:
registry: [ DOCKER_REGISTRY_IMAGE, GITHUB_REGISTRY_IMAGE ]
steps:
- name: Checkout Repo
uses: actions/checkout@v3
Expand Down Expand Up @@ -144,8 +123,7 @@ jobs:
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
images: |
${{ env.DOCKER_REGISTRY_IMAGE }}
${{ env.GITHUB_REGISTRY_IMAGE }}
${{ env[matrix.registry] }}
flavor: |
latest=false
tags: |
Expand All @@ -155,18 +133,18 @@ jobs:
working-directory: /tmp/digests/dockerhub
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.DOCKER_REGISTRY_IMAGE }}@sha256:%s ' *)
$(printf '${{ env[matrix.registry] }}@sha256:%s ' *)
- name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.DOCKER_REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}
docker buildx imagetools inspect ${{ env[matrix.registry]}}:${{ steps.meta.outputs.version }}
- name: Create manifest list and push (Github Container Registry)
working-directory: /tmp/digests/ghcr
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.GITHUB_REGISTRY_IMAGE }}@sha256:%s ' *)
# - name: Create manifest list and push (Github Container Registry)
# working-directory: /tmp/digests/ghcr
# run: |
# docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
# $(printf '${{ env.GITHUB_REGISTRY_IMAGE }}@sha256:%s ' *)

- name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.GITHUB_REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}
# - name: Inspect image
# run: |
# docker buildx imagetools inspect ${{ env.GITHUB_REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}

0 comments on commit f14ab99

Please sign in to comment.