1- name : buildx_dockerhub
1+ name : buildx
22
33on :
44 create :
1616 name : Prepare
1717 id : prepare
1818 run : |
19- DOCKER_IMAGE=windoac/nginx-npm
19+ DOCKER_IMAGE_dockerhub=windoac/nginx-npm
20+ DOCKER_IMAGE_github=ghcr.io/windoc/nginx-npm
2021 DOCKER_PLATFORMS=linux/amd64,linux/arm/v7,linux/arm64/v8
2122 VERSION=edge
2223
@@ -25,12 +26,16 @@ jobs:
2526 VERSION=$(echo $VERSION | sed 's/^v//g')
2627 fi
2728
28- TAGS="--tag ${DOCKER_IMAGE}:${VERSION}"
29+ TAGS="--tag ${DOCKER_IMAGE_dockerhub}:${VERSION}"
30+ TAGS="$TAGS --tag ${DOCKER_IMAGE_github}:${VERSION}"
2931 if [[ $VERSION =~ ^[0-9]{1,3} ]]; then
30- TAGS="$TAGS --tag ${DOCKER_IMAGE}:latest"
32+ # add latest
33+ TAGS="$TAGS --tag ${DOCKER_IMAGE_dockerhub}:latest"
34+ TAGS="$TAGS --tag ${DOCKER_IMAGE_github}:latest"
3135 fi
3236
33- echo "docker_image=${DOCKER_IMAGE}" >> $GITHUB_OUTPUT
37+ echo "docker_image_dockerhub=${DOCKER_IMAGE_dockerhub}" >> $GITHUB_OUTPUT
38+ echo "docker_image_github=${DOCKER_IMAGE_github}" >> $GITHUB_OUTPUT
3439 echo "version=${VERSION}" >> $GITHUB_OUTPUT
3540 echo "buildx_args=--platform ${DOCKER_PLATFORMS} --build-arg VERSION=${VERSION} --build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') --build-arg VCS_REF=${GITHUB_SHA::8} ${TAGS} --file ./Dockerfile ." >> $GITHUB_OUTPUT
3641 # https://github.com/docker/setup-qemu-action
@@ -51,17 +56,30 @@ jobs:
5156 -
5257 name : Login to DockerHub
5358 if : success() && github.event_name != 'pull_request'
54- uses : docker/login-action@v2
59+ uses : docker/login-action@v1
5560 with :
5661 username : ${{ secrets.DOCKER_USERNAME }}
5762 password : ${{ secrets.DOCKER_PASSWORD }}
63+ -
64+ name : Login to ghcr.io
65+ if : success() && github.event_name != 'pull_request'
66+ uses : docker/login-action@v2
67+ with :
68+ registry : ghcr.io
69+ username : ${{ github.actor }}
70+ password : ${{ secrets.GITHUB_TOKEN }}
5871 -
5972 name : Docker Buildx (push)
6073 if : success() && github.event_name != 'pull_request'
6174 run : |
6275 docker buildx build --output "type=image,push=true" ${{ steps.prepare.outputs.buildx_args }}
6376 -
64- name : Inspect image
77+ name : Inspect image (DockerHub)
78+ if : always() && github.event_name != 'pull_request'
79+ run : |
80+ docker buildx imagetools inspect ${{ steps.prepare.outputs.docker_image_dockerhub }}:${{ steps.prepare.outputs.version }}
81+ -
82+ name : Inspect image (GitHub)
6583 if : always() && github.event_name != 'pull_request'
6684 run : |
67- docker buildx imagetools inspect ${{ steps.prepare.outputs.docker_image }}:${{ steps.prepare.outputs.version }}
85+ docker buildx imagetools inspect ${{ steps.prepare.outputs.docker_image_github }}:${{ steps.prepare.outputs.version }}
0 commit comments