Skip to content

Mirror Docker Image to GHCR #6

Mirror Docker Image to GHCR

Mirror Docker Image to GHCR #6

Workflow file for this run

name: Mirror Docker Image to GHCR
on:
workflow_dispatch:
inputs:
image_name:
description: 'Docker image name (e.g., myorg/myimage:tag)'
required: true
env:
REGISTRY: ghcr.io
jobs:
publish-to-ghcr:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Validate image
run: |
IMAGE="${{ github.event.inputs.image_name }}"
if [[ "$IMAGE" == *.* ]]; then
echo "Image name contains a domain, exiting. Only short dockerhub image names are allowed"
exit 1
fi
- name: Checkout repository
uses: actions/checkout@v4
- name: 'Set up skopeo'
uses: warjiang/[email protected]
with:
version: latest
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Copy image to GHCR
env:
IMAGE: ${{ github.event.inputs.image_name }}
run: |
skopeo copy \
--dest-creds="${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}" \
"docker://${{ github.event.inputs.image_name }}" \
"docker://${{ env.REGISTRY }}/1mgr/${{ github.event.inputs.image_name }}"