Skip to content

Commit

Permalink
extend build actions to copy docker images to old dockerhub repository
Browse files Browse the repository at this point in the history
  • Loading branch information
pk910 committed Dec 16, 2023
1 parent 0a04701 commit 910aeb4
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 0 deletions.
67 changes: 67 additions & 0 deletions .github/workflows/_shared-docker-clone.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@

name: Reusable docker clone workflow
on:
workflow_call:
inputs:
source_repository:
description: 'Source Docker Hub Repository'
default: ''
required: false
type: string
target_repository:
description: 'Target Docker Hub Repository'
default: ''
required: false
type: string
tags:
description: 'Docker Image Tags (JSON)'
default: ''
required: false
type: string
secrets:
DOCKERHUB_USERNAME:
description: 'Docker Hub Username'
required: false
DOCKERHUB_TOKEN:
description: 'Docker Hub Token'
required: false

# shared build jobs
jobs:
clone_docker_images:
name: Clone docker images to ${{ inputs.target_repository }}
if: ${{ inputs.tags }}
runs-on: ubuntu-latest
strategy:
matrix:
tag: ${{ fromJSON(inputs.tags) }}
steps:

# prepare docker
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Get tag names
id: tags
run: |
tagstr="${{ matrix.tag }}"
tagparts=(${tagstr//:/ })
echo "source_tag=${tagparts[0]}" >> $GITHUB_OUTPUT
if [ -z "$tagparts[1]" ]; then
echo "target_tag=${tagparts[0]}" >> $GITHUB_OUTPUT
else
echo "target_tag=${tagparts[1]}" >> $GITHUB_OUTPUT
fi
# build multiarch image
- name: "Copy docker image: ${{ steps.tags.outputs.target_tag }}"
run: |
docker buildx imagetools create -t ${{ inputs.target_repository }}:${{ steps.tags.outputs.target_tag }} \
${{ inputs.source_repository }}:${{ steps.tags.outputs.source_tag }}-amd64 \
${{ inputs.source_repository }}:${{ steps.tags.outputs.source_tag }}-arm64
12 changes: 12 additions & 0 deletions .github/workflows/build-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,18 @@ jobs:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}

clone_docker_images:
name: "Copy docker images"
needs: [build_binaries]
uses: ./.github/workflows/_shared-docker-clone.yaml
with:
source_repository: "ethpandaops/dora"
target_repository: "pk910/dora-the-explorer"
tags: "['master:unstable']"
secrets:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_PK_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_PK_TOKEN }}

create_snapshot_release:
name: Create snapshot release
needs: [build_binaries]
Expand Down
12 changes: 12 additions & 0 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ jobs:
secrets:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}

clone_docker_images:
name: "Copy docker images"
needs: [build_binaries]
uses: ./.github/workflows/_shared-docker-clone.yaml
with:
source_repository: "ethpandaops/dora"
target_repository: "pk910/dora-the-explorer"
tags: "['v${{ inputs.version }}','v${{ inputs.version }}:latest']"
secrets:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_PK_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_PK_TOKEN }}

create_release:
name: Create Release
Expand Down

0 comments on commit 910aeb4

Please sign in to comment.