Skip to content

Commit

Permalink
sync docker.io to GAR (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
joecorall committed Nov 16, 2024
1 parent 7726b24 commit 207f16e
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/sync.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: hub.docker.com -> us-docker.pkg.dev

on:
schedule:
- cron: "0 7 * * *"
workflow_dispatch:

jobs:
sync-images:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- name: checkout
uses: actions/checkout@v4

- name: Authenticate to Google Cloud
id: 'auth'
uses: google-github-actions/auth@v1
with:
workload_identity_provider: ${{ secrets.GCLOUD_OIDC_POOL }}
service_account: ${{ secrets.GSA }}
token_format: 'access_token'

- uses: docker/login-action@v3
name: 'Docker login'
with:
registry: 'us-docker.pkg.dev'
username: 'oauth2accesstoken'
password: '${{ steps.auth.outputs.access_token }}'

- name: pull+push
run: |
REPOS=$(curl -s "https://hub.docker.com/v2/repositories/lehighlts/?page_size=100" | \
jq -r '.results[] | select(.name | startswith("scyllaridae-")) | .name')
for REPO in $REPOS; do
SOURCE="lehighlts/$REPO:main"
TARGET="us-docker.pkg.dev/${{ secrets.GCLOUD_PROJECT }}/shared/$REPO:main"
docker pull "$SOURCE"
docker tag "$SOURCE" "$TARGET"
docker push "$TARGET"
done

0 comments on commit 207f16e

Please sign in to comment.