Mirror image to GHCR #3
This file contains hidden or 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 image to GHCR | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| image: | |
| description: "Source image to mirror (e.g. mcr.microsoft.com/dotnet/sdk)" | |
| required: true | |
| type: string | |
| tag: | |
| description: "Image tag to mirror (e.g. 8.0, 8.0-alpine)" | |
| required: true | |
| type: string | |
| permissions: | |
| packages: write | |
| jobs: | |
| mirror: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Log in to GHCR | |
| uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Resolve GHCR target | |
| env: | |
| IMAGE: ${{ inputs.image }} | |
| REPOSITORY: ${{ github.repository }} | |
| run: | | |
| GHCR_TARGET="$(echo "ghcr.io/${REPOSITORY}/${IMAGE}" | tr '[:upper:]' '[:lower:]')" | |
| echo "GHCR_TARGET=${GHCR_TARGET}" >> $GITHUB_ENV | |
| - name: Mirror manifest to GHCR | |
| env: | |
| SOURCE: ${{ inputs.image }} | |
| TAG: ${{ inputs.tag }} | |
| run: | | |
| docker buildx imagetools create \ | |
| --tag "${GHCR_TARGET}:${TAG}" \ | |
| "${SOURCE}:${TAG}" |