Skip to content

Commit

Permalink
Remove build tags and fix manifest publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
williamdes committed Jan 28, 2024
1 parent 6275c2f commit 656a6c8
Showing 1 changed file with 57 additions and 12 deletions.
69 changes: 57 additions & 12 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,17 @@ jobs:
# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push image
run: make build-alpine
env:
DOCKER_BUILDKIT: 1
ACTION: push
PLATFORM: "${{ matrix.platform }}"
IMAGE_TAG: "docker.io/hickorydns/hickory-dns:${{ matrix.platform-tag }}-latest"
#- name: Build and push image
# run: make build-alpine
# env:
# DOCKER_BUILDKIT: 1
# ACTION: push
# PLATFORM: "${{ matrix.platform }}"
# IMAGE_TAG: "docker.io/hickorydns/hickory-dns:${{ matrix.platform-tag }}-latest"

- name: Test docker image
if: ${{ matrix.platform == 'linux/amd64' }}
run: make test-alpine
#- name: Test docker image
# if: ${{ matrix.platform == 'linux/amd64' }}
# run: make test-alpine

build-and-push-manifest:
name: Build and push the docker hub manifest
Expand All @@ -83,9 +83,54 @@ jobs:
docker.io/hickorydns/hickory-dns:armv6-latest \
docker.io/hickorydns/hickory-dns:ppc64le-latest \
docker.io/hickorydns/hickory-dns:s390x-latest \
docker.io/hickorydns/hickory-dns:386-latest \
--amend
docker.io/hickorydns/hickory-dns:386-latest
- name: Push the manifest
env:
DOCKER_CLI_EXPERIMENTAL: enabled
run: docker manifest push docker.io/hickorydns/hickory-dns:latest
- name: Inspect the manifest
run: docker manifest inspect docker.io/hickorydns/hickory-dns:latest

tags-cleanup:
runs-on: ubuntu-latest
needs: build-and-push-manifest
environment:
name: "docker-hub"
url: https://hub.docker.com/r/hickorydns/hickory-dns
name: Cleanup DockerHub build tags
steps:
- name: Install Docker hub-tool
run: |
curl -sL https://github.com/docker/hub-tool/releases/download/v0.4.5/hub-tool-linux-amd64.tar.gz -o hub-tool-linux.tar.gz
tar --strip-components=1 -xzf ./hub-tool-linux.tar.gz
./hub-tool --version
- name: Login to DockerHub using hub-tool
run: |
set -eu
# Fool the login command (https://github.com/docker/hub-tool/pull/198)
# ./hub-tool login
# Token commands thank to https://stackoverflow.com/a/59334315/5155484
HUB_TOKEN=$(curl -s -H "Content-Type: application/json" -X POST -d "{\"username\": \"$DOCKER_USERNAME\", \"password\": \"$DOCKER_PASSWORD\"}" https://hub.docker.com/v2/users/login/ | jq -r .token)
USERNAME="$(printf '%s:' "$DOCKER_USERNAME" | base64 -w0)"
USER_PASS="$(printf '%s:%s' "$DOCKER_USERNAME" "$DOCKER_PASSWORD" | base64 -w0)"
mkdir -p ~/.docker/
printf '{"auths": {"hub-tool": {"auth": "%s"}, "hub-tool-refresh-token": {"auth": "%s"}, "hub-tool-token": { "auth": "%s", "identitytoken": "%s"}}}' \
"$USER_PASS" "$USERNAME" \
"$USERNAME" "$HUB_TOKEN" \
> ~/.docker/config.json
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_HUB_USER }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: Remove DockerHub tags via hub-tool
run: |
./hub-tool tag rm --verbose --force docker.io/hickorydns/hickory-dns:arm64-latest || true
./hub-tool tag rm --verbose --force docker.io/hickorydns/hickory-dns:amd64-latest || true
./hub-tool tag rm --verbose --force docker.io/hickorydns/hickory-dns:armv7-latest || true
./hub-tool tag rm --verbose --force docker.io/hickorydns/hickory-dns:armv6-latest || true
./hub-tool tag rm --verbose --force docker.io/hickorydns/hickory-dns:ppc64le-latest || true
./hub-tool tag rm --verbose --force docker.io/hickorydns/hickory-dns:s390x-latest || true
./hub-tool tag rm --verbose --force docker.io/hickorydns/hickory-dns:386-latest || true
./hub-tool tag ls --verbose docker.io/hickorydns/hickory-dns
- name: Logout hub-tool
if: always()
run: rm ~/.docker/config.json

0 comments on commit 656a6c8

Please sign in to comment.