From 03b93275657443cdff66d21930df3480fa4c8a28 Mon Sep 17 00:00:00 2001 From: WoLfulus Date: Thu, 1 Oct 2020 14:44:04 -0300 Subject: [PATCH] Added push to docker hub --- .../build-images/rootfs/usr/bin/entrypoint | 15 ++++++++++----- .github/workflows/build-images.yml | 11 ++++++++++- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/.github/actions/build-images/rootfs/usr/bin/entrypoint b/.github/actions/build-images/rootfs/usr/bin/entrypoint index 16ebb0020c..eb07e51086 100644 --- a/.github/actions/build-images/rootfs/usr/bin/entrypoint +++ b/.github/actions/build-images/rootfs/usr/bin/entrypoint @@ -66,7 +66,7 @@ function main() { push=$(argument push "false") latest=$(argument latest "false") - registry=$(argument registry "ghcr.io") + registry=$(argument registry "") registry=$(echo "${registry}" | tr '[:upper:]' '[:lower:]') repository=$(argument repository "directus/next") @@ -75,6 +75,11 @@ function main() { version=$(argument version "") context=$(argument context ".") + image="${repository}" + if [ "${registry}" != "" ]; then + image="${registry}/${image}" + fi + # Normalize tag if [ "${version}" == "" ]; then version=${GITHUB_REF##*/} @@ -102,7 +107,7 @@ function main() { # Push latest # TODO: check if it's really the latest if [ "${latest}" == "true" ]; then - fqin="${registry}/${repository}:latest" + fqin="${image}:latest" echo "Tagging ${fqin}" docker tag directus:main ${fqin} if [ "${push}" == "true" ]; then @@ -115,12 +120,12 @@ function main() { for tag in $tags do tag=$(echo "${tag}" | tr '[:upper:]' '[:lower:]') - fqin="${registry}/${repository}:latest" + fqin="${image}:${tag}" echo "Tagging ${fqin}" - docker tag directus:main "${registry}/${repository}:${tag}" + docker tag directus:main "${fqin}" if [ "${push}" == "true" ]; then echo "Pushing tag ${fqin}" - docker push "${registry}/${repository}:${tag}" + docker push "${fqin}" fi done diff --git a/.github/workflows/build-images.yml b/.github/workflows/build-images.yml index 2e70b28ff5..2674bbb249 100644 --- a/.github/workflows/build-images.yml +++ b/.github/workflows/build-images.yml @@ -11,7 +11,7 @@ jobs: - name: Checkout uses: actions/checkout@v2 - - name: Build + - name: Build GitHub Container Registry uses: ./.github/actions/build-images with: registry: "ghcr.io" @@ -20,3 +20,12 @@ jobs: password: "${{ secrets.REGISTRY_PASSWORD }}" version: "${{ github.ref }}" push: "true" + + - name: Build Docker Hub + uses: ./.github/actions/build-images + with: + repository: "${{ github.repository }}" + username: "${{ secrets.DOCKERHUB_USERNAME }}" + password: "${{ secrets.DOCKERHUB_PASSWORD }}" + version: "${{ github.ref }}" + push: "true"