Skip to content

Instantly share code, notes, and snippets.

View ferferga's full-sized avatar
💭
I may be slow to respond (429 Too Many Requests)

Fernando Fernández ferferga

💭
I may be slow to respond (429 Too Many Requests)
  • Spain
  • 21:40 (UTC +02:00)
View GitHub Profile
@ferferga
ferferga / delete_ghcr_dangling_images.sh
Created September 7, 2021 17:12
Deletes untagged images from GitHub Container Registry package using gh cli
#!/bin/bash
set -e
# Simple script to remove dangling images from GHCR.
# You need to have installed gh cli and jq for this script to work properly
# You need to be logged to 'gh' first
container="debian/buildd"
temp_file="ghcr_prune.ids"
rm -rf $temp_file
@ferferga
ferferga / sync_image_ghcr.sh
Created September 7, 2021 17:08
Simple script that pushes missing/outdated tags from an image in DockerHub to GitHub Container Registry, skipping up-to-date tags. You can run this with a cron to sync your DockerHub images with GHCR.
#!/bin/bash
set -e
# Simple script that pushes missing/outdated tags from an image in DockerHub to GHCR, skipping up-to-date tags.
# You need to be logged in using 'docker login' first: https://docs.github.com/es/packages/working-with-a-github-packages-registry/working-with-the-container-registry
# You also need jq and wget installed in your system for this script to work
target_repo="ghcr.io"
tag_file="tag_list.txt"
# Replace this with the name of your image
@ferferga
ferferga / transfer_ghcr.sh
Created February 25, 2021 19:45
Copy all the images and tags from an user in DockerHub to ghcr.io
#!/bin/bash
# Simple script to repush docker images from one repository to another
username="ferferga"
# Github package registry. You need to be logged in first
target_repo="ghcr.io"
img_file="image_list.txt"
tag_file="tag_list.txt"
rm -rf $img_file
wget -q https://hub.docker.com/v2/repositories/$username/ -O - | jq -r '.results[] | . | .namespace + "/" + .name' >> $img_file