This is an automated email from the ASF dual-hosted git repository.
adoroszlai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone-docker-runner.git
The following commit(s) were added to refs/heads/master by this push:
new c36597a HDDS-11634. Publish images to Docker Hub from GitHub workflow
(#33)
c36597a is described below
commit c36597a55b23e95719fde77986e4ea898c5d9090
Author: Doroszlai, Attila <[email protected]>
AuthorDate: Fri Nov 8 06:47:36 2024 +0100
HDDS-11634. Publish images to Docker Hub from GitHub workflow (#33)
---
.github/workflows/build-and-tag.yaml | 25 +++++++++++++++++++++----
1 file changed, 21 insertions(+), 4 deletions(-)
diff --git a/.github/workflows/build-and-tag.yaml
b/.github/workflows/build-and-tag.yaml
index 199cc0b..8544a6c 100644
--- a/.github/workflows/build-and-tag.yaml
+++ b/.github/workflows/build-and-tag.yaml
@@ -33,18 +33,25 @@ jobs:
if: ${{ github.ref_type == 'tag' }}
runs-on: ubuntu-latest
env:
+ DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }}
IMAGE_ID: ${{ needs.build.outputs.image-id }}
+ REGISTRIES: ghcr.io # docker.io is appended dynamically
steps:
- name: Generate tags
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81
with:
images: |
- ghcr.io/${{ github.repository_owner }}/ozone-runner
+ ${{ github.repository_owner }}/ozone-runner
tags: |
type=ref,event=tag
flavor: |
latest=false
+ - name: Add Docker Hub to targets
+ if: ${{ env.DOCKERHUB_USER }}
+ run: |
+ echo "REGISTRIES=${{ env.REGISTRIES }} docker.io" >> $GITHUB_ENV
+
- name: Pull image
run: |
docker pull "$IMAGE_ID"
@@ -56,9 +63,19 @@ jobs:
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
+ - name: Login to Docker Hub
+ if: ${{ env.DOCKERHUB_USER }}
+ uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567
+ with:
+ username: ${{ env.DOCKERHUB_USER }}
+ password: ${{ secrets.DOCKERHUB_TOKEN }}
+
- name: Apply tags to existing image
run: |
- for tag in $DOCKER_METADATA_OUTPUT_TAGS; do
- docker tag "$IMAGE_ID" "$tag"
- docker push "$tag"
+ set -x
+ for registry in $REGISTRIES; do
+ opts="$(echo "$DOCKER_METADATA_OUTPUT_TAGS" | sed "s@^@--tag
$registry/@g" | xargs echo)"
+ if [[ -n "$opts" ]]; then
+ docker buildx imagetools create $opts "$IMAGE_ID"
+ fi
done
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]