hub.docker.com -> us-docker.pkg.dev #32
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
docker pull islandora/fits:main | |
docker tag islandora/fits:main us-docker.pkg.dev/${{ secrets.GCLOUD_PROJECT }}/shared/harvard-fits:main | |
docker push us-docker.pkg.dev/${{ secrets.GCLOUD_PROJECT }}/shared/harvard-fits:main |