From a49e55e0aa596110b8d15c7f12546fa5afa6b16f Mon Sep 17 00:00:00 2001 From: Till Rohrmann Date: Mon, 27 Nov 2023 21:57:04 +0100 Subject: [PATCH] Update docker.yml to optionally upload to DockerHub --- .github/workflows/docker.yml | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 979abd564a..21339947b7 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -18,6 +18,11 @@ on: required: false default: false type: boolean + uploadToDockerHub: + description: 'upload image to DockerHub' + required: false + default: false + type: boolean workflow_dispatch: inputs: @@ -26,10 +31,13 @@ on: required: false default: false type: boolean + uploadToDockerHub: + description: 'upload image to DockerHub' + required: false + default: false + type: boolean env: - REGISTRY: 'ghcr.io' - REPOSITORY: ${{ github.repository_owner }} REGISTRY_USERNAME: ${{ github.actor }} REGISTRY_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -61,11 +69,18 @@ jobs: run: | echo "IMAGE_NAME=${GITHUB_REPOSITORY#$GITHUB_REPOSITORY_OWNER/}" >> $GITHUB_ENV + - name: Print image names + run: | + echo ${{ inputs.uploadToDockerHub && format('restatedev/{0}', env.IMAGE_NAME) || '' }} + - name: Extract metadata (tags, labels) for Docker id: meta uses: docker/metadata-action@v4 with: - images: ${{ env.REGISTRY }}/${{ env.REPOSITORY }}/${{ env.IMAGE_NAME }} + images: | + ghcr.io/restatedev/${{ env.IMAGE_NAME }} + ${{ inputs.uploadToDockerHub && format('restatedev/{0}', env.IMAGE_NAME) || '' }} + # Note: We need this to generate the latest tag until we have a first stable release. # Check https://github.com/docker/metadata-action/issues/34 flavor: |