Skip to content

Commit

Permalink
group both buildx of dockerhub and github
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonio Cheong committed Jul 26, 2024
1 parent 42d7ffd commit 08792c0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 75 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: buildx_github
name: buildx

on:
create:
Expand All @@ -16,7 +16,8 @@ jobs:
name: Prepare
id: prepare
run: |
DOCKER_IMAGE=ghcr.io/windoc/docker-bind
DOCKER_IMAGE_dockerhub=windoac/docker-bind
DOCKER_IMAGE_github=ghcr.io/windoc/docker-bind
DOCKER_PLATFORMS=linux/amd64,linux/arm/v7,linux/arm64/v8
VERSION=edge
Expand All @@ -25,12 +26,16 @@ jobs:
VERSION=$(echo $VERSION | sed 's/^v//g')
fi
TAGS="--tag ${DOCKER_IMAGE}:${VERSION}"
TAGS="--tag ${DOCKER_IMAGE_dockerhub}:${VERSION}"
TAGS="$TAGS --tag ${DOCKER_IMAGE_github}:${VERSION}"
if [[ $VERSION =~ ^[0-9]{1,3} ]]; then
TAGS="$TAGS --tag ${DOCKER_IMAGE}:latest"
# add tag 8.0 and latest
TAGS="$TAGS --tag ${DOCKER_IMAGE_dockerhub}:latest"
TAGS="$TAGS --tag ${DOCKER_IMAGE_github}:latest"
fi
echo "docker_image=${DOCKER_IMAGE}" >> $GITHUB_OUTPUT
echo "docker_image_dockerhub=${DOCKER_IMAGE_dockerhub}" >> $GITHUB_OUTPUT
echo "docker_image_github=${DOCKER_IMAGE_github}" >> $GITHUB_OUTPUT
echo "version=${VERSION}" >> $GITHUB_OUTPUT
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
# https://github.com/docker/setup-qemu-action
Expand All @@ -48,6 +53,13 @@ jobs:
name: Docker Buildx (build)
run: |
docker buildx build --output "type=image,push=false" ${{ steps.prepare.outputs.buildx_args }}
-
name: Login to DockerHub
if: success() && github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
-
name: Login to ghcr.io
if: success() && github.event_name != 'pull_request'
Expand All @@ -57,12 +69,17 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Docker Buildx (push to ghcr.io)
name: Docker Buildx (push)
if: success() && github.event_name != 'pull_request'
run: |
docker buildx build --output "type=image,push=true" ${{ steps.prepare.outputs.buildx_args }}
-
name: Inspect image
name: Inspect image (DockerHub)
if: always() && github.event_name != 'pull_request'
run: |
docker buildx imagetools inspect ${{ steps.prepare.outputs.docker_image_dockerhub }}:${{ steps.prepare.outputs.version }}
-
name: Inspect image (GitHub)
if: always() && github.event_name != 'pull_request'
run: |
docker buildx imagetools inspect ${{ steps.prepare.outputs.docker_image }}:${{ steps.prepare.outputs.version }}
docker buildx imagetools inspect ${{ steps.prepare.outputs.docker_image_github }}:${{ steps.prepare.outputs.version }}
67 changes: 0 additions & 67 deletions .github/workflows/buildx_dockerhub.yml

This file was deleted.

0 comments on commit 08792c0

Please sign in to comment.