From 73972d0d76dc178060511fe1d070d910e384c468 Mon Sep 17 00:00:00 2001 From: Alex Gartner Date: Tue, 30 Jul 2024 15:01:24 -0700 Subject: [PATCH] Initial commit --- .github/workflows/copy.yml | 37 +++++++++++++++++++++++++++++++++++++ copy.sh | 20 ++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 .github/workflows/copy.yml create mode 100755 copy.sh diff --git a/.github/workflows/copy.yml b/.github/workflows/copy.yml new file mode 100644 index 0000000..64a62b0 --- /dev/null +++ b/.github/workflows/copy.yml @@ -0,0 +1,37 @@ +name: copy + +on: + push: + branches: + - main + +jobs: + copy: + runs-on: ubuntu-latest + + permissions: + packages: write + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Login to Docker Hub registry + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_READ_ONLY }} + - name: Login to github docker registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - uses: imjasonh/setup-crane@v0.4 + # this will fail the first time when copying an image :/ + - name: copy + uses: nick-fields/retry@v3 + with: + timeout_minutes: 5 + max_attempts: 2 + command: ./copy.sh \ No newline at end of file diff --git a/copy.sh b/copy.sh new file mode 100755 index 0000000..7c8fbef --- /dev/null +++ b/copy.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +set -eo pipefail + +target_registry=$1 + +source_images=( + # localnet test images + "ruimarinho/bitcoin-core:22" + "ethereum/client-go:v1.10.26" + + # localnet build images + "golang:1.22.5-bookworm" +) + +for source_image in "${source_images[@]}"; do + # replaces slashes in images names with dashes + target_image_name=$(echo "${source_image}" | tr '/' '-') + crane copy "${source_image}" "${target_registry}/${target_image_name}" +done \ No newline at end of file