Skip to content

Commit b9bdade

Browse files
committed
workflow: reusable mirror workflow
1 parent 8e38d8b commit b9bdade

1 file changed

Lines changed: 5 additions & 43 deletions

File tree

.github/workflows/build.yml

Lines changed: 5 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -28,48 +28,10 @@ jobs:
2828
secrets: inherit
2929

3030
mirror-to-ghcr:
31-
runs-on: ubuntu-latest
3231
needs: build
3332
if: startsWith(github.ref, 'refs/tags/v')
34-
steps:
35-
- name: Extract version
36-
id: version
37-
run: |
38-
TAG=${GITHUB_REF#refs/tags/}
39-
VERSION=${TAG#v}
40-
MAJOR=$(echo $VERSION | cut -d. -f1)
41-
MINOR=$(echo $VERSION | cut -d. -f2)
42-
echo "tag=$TAG" >> $GITHUB_OUTPUT
43-
echo "version=$VERSION" >> $GITHUB_OUTPUT
44-
echo "major=$MAJOR" >> $GITHUB_OUTPUT
45-
echo "minor=$MINOR" >> $GITHUB_OUTPUT
46-
47-
- name: Log in to GitHub Container Registry
48-
uses: docker/login-action@v3
49-
with:
50-
registry: ghcr.io
51-
username: ${{ github.actor }}
52-
password: ${{ secrets.GITHUB_TOKEN }}
53-
54-
- name: Set up Docker Buildx
55-
uses: docker/setup-buildx-action@v3
56-
57-
- name: Mirror multi-platform images to GHCR
58-
run: |
59-
# Use buildx imagetools to mirror all platforms from Docker Hub to GHCR
60-
SOURCE_IMAGE="jimschubert/labeler:${{ steps.version.outputs.tag }}"
61-
TARGET_IMAGE="ghcr.io/jimschubert/labeler/labeler"
62-
63-
# Inspect source to verify it exists and show platforms
64-
echo "Source image platforms:"
65-
docker buildx imagetools inspect ${SOURCE_IMAGE}
66-
67-
# Mirror all platforms with multiple tags
68-
docker buildx imagetools create \
69-
--tag ${TARGET_IMAGE}:${{ steps.version.outputs.tag }} \
70-
--tag ${TARGET_IMAGE}:v${{ steps.version.outputs.major }} \
71-
--tag ${TARGET_IMAGE}:v${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }} \
72-
--tag ${TARGET_IMAGE}:latest \
73-
${SOURCE_IMAGE}
74-
75-
echo "Successfully mirrored all platforms to GHCR"
33+
uses: jimschubert/.workflows/.github/workflows/docker-mirror.yml@main
34+
with:
35+
source-image: jimschubert/labeler:${{ github.ref_name }}
36+
target-image: ghcr.io/jimschubert/labeler/labeler
37+
secrets: inherit

0 commit comments

Comments
 (0)