Mirror Docker Image to GHCR #35
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: Mirror Docker Image to GHCR | |
on: | |
workflow_dispatch: | |
inputs: | |
image_name: | |
description: 'Docker image name (e.g., myorg/myimage:tag)' | |
required: true | |
id: | |
description: 'Job id to identify workflow' # https://stackoverflow.com/a/69500478/3443964 | |
required: false | |
env: | |
REGISTRY: ghcr.io | |
jobs: | |
id: | |
name: Workflow ID Provider | |
runs-on: ubuntu-latest | |
steps: | |
- name: ${{github.event.inputs.id}} | |
run: echo run identifier ${{ inputs.id }} | |
publish-to-ghcr: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- 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 }}" |