aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Ben Kochie <superq@gmail.com> 2024-03-25 21:31:01 +0100
committerGravatar GitHub <noreply@github.com> 2024-03-25 21:31:01 +0100
commit1366272f40e3be8ad1fd56ee712abede4ee22b80 (patch)
tree1ae14ae52699cc36ffc93446001183e369566306
parent9380fe3d9e9fc47b1da5e57e44a60136e7dd365b (diff)
downloadcoredns-1366272f40e3be8ad1fd56ee712abede4ee22b80.tar.gz
coredns-1366272f40e3be8ad1fd56ee712abede4ee22b80.tar.zst
coredns-1366272f40e3be8ad1fd56ee712abede4ee22b80.zip
Use Docker login action (#6567)
Use `docker/login-action` instead of handling Docker login in the Makfile. This fixes special character handling in the Makefile as well as allowing future pushing to other container registries. Signed-off-by: SuperQ <superq@gmail.com>
-rw-r--r--.github/workflows/docker.yml5
-rw-r--r--Makefile.docker3
2 files changed, 6 insertions, 2 deletions
diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml
index a74b81b6d..67ef06f4f 100644
--- a/.github/workflows/docker.yml
+++ b/.github/workflows/docker.yml
@@ -25,5 +25,10 @@ jobs:
run: make VERSION=${RELEASE:1} DOCKER=coredns -f Makefile.docker release
- name: Show Docker Images
run: docker images
+ - name: Docker login
+ uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # v3.1.0
+ with:
+ username: ${{ secrets.DOCKERHUB_USERNAME }}
+ password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Publish Docker Images
run: make VERSION=${RELEASE:1} DOCKER=coredns -f Makefile.docker docker-push
diff --git a/Makefile.docker b/Makefile.docker
index fb8cb8efe..c75f3cfd3 100644
--- a/Makefile.docker
+++ b/Makefile.docker
@@ -102,7 +102,6 @@ else
@# Pushes coredns/coredns-$arch:$version images
@# Creates manifest for multi-arch image
@# Pushes multi-arch image to coredns/coredns:$version
- @echo $(DOCKER_PASSWORD) | docker login -u $(DOCKER_LOGIN) --password-stdin
@echo Pushing: $(VERSION) to $(DOCKER_IMAGE_NAME)
for arch in $(LINUX_ARCH); do \
docker push $(DOCKER_IMAGE_NAME):$${arch}-$(VERSION) ;\
@@ -111,7 +110,7 @@ else
docker manifest create --amend $(DOCKER_IMAGE_NAME):latest $(DOCKER_IMAGE_LIST_VERSIONED)
docker manifest push --purge $(DOCKER_IMAGE_NAME):$(VERSION)
docker manifest push --purge $(DOCKER_IMAGE_NAME):latest
- TOKEN=$$(curl -s -H "Content-Type: application/json" -X POST -d "{\"username\":\"$(DOCKER_LOGIN)\",\"password\":\"$(DOCKER_PASSWORD)\"}" "https://hub.docker.com/v2/users/login/" | jq -r .token) ; \
+ TOKEN=$$(curl -s -H "Content-Type: application/json" -X POST -d "{\"username\":\"$${DOCKER_LOGIN}\",\"password\":\"$${DOCKER_PASSWORD}\"}" "https://hub.docker.com/v2/users/login/" | jq -r .token) ; \
for arch in $(LINUX_ARCH); do \
curl -X DELETE -H "Authorization: JWT $${TOKEN}" "https://hub.docker.com/v2/repositories/$(DOCKER_IMAGE_NAME)/tags/$${arch}-$(VERSION)/" ;\
done