Skip to content

Commit 799785d

Browse files
committed
Add dockerio mirror
1 parent 031822e commit 799785d

1 file changed

Lines changed: 72 additions & 0 deletions

File tree

‎.github/workflows/dockerio.yaml‎

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: dockerio
2+
on:
3+
push:
4+
workflow_dispatch:
5+
inputs:
6+
image:
7+
description: 'Docker Hub image (e.g., nginx, library/alpine)'
8+
required: true
9+
type: string
10+
schedule:
11+
- cron: '0 0 * * *' # Daily at midnight UTC
12+
13+
env:
14+
# Define images to mirror (format: source -> mirrored to ghcr.io/$REPO/docker.io/source)
15+
IMAGES: |
16+
netbirdio/management
17+
netbirdio/dashboard
18+
netbirdio/relay
19+
netbirdio/signal
20+
21+
jobs:
22+
# Build matrix of images to mirror
23+
prepare:
24+
runs-on: ubuntu-latest
25+
outputs:
26+
matrix: ${{ steps.set-matrix.outputs.matrix }}
27+
steps:
28+
- id: set-matrix
29+
run: |
30+
if [ -n "${{ inputs.image }}" ]; then
31+
# Manual trigger - single image
32+
echo "matrix=[\"${{ inputs.image }}\"]" >> $GITHUB_OUTPUT
33+
else
34+
# Scheduled - all images from IMAGES env
35+
MATRIX=$(echo "$IMAGES" | grep -v '^$' | jq -R -s -c 'split("\n") | map(select(length > 0))')
36+
echo "matrix=$MATRIX" >> $GITHUB_OUTPUT
37+
fi
38+
39+
mirror:
40+
needs: prepare
41+
runs-on: ubuntu-latest
42+
permissions:
43+
packages: write
44+
strategy:
45+
fail-fast: false
46+
max-parallel: 4 # Parallel image mirroring
47+
matrix:
48+
image: ${{ fromJson(needs.prepare.outputs.matrix) }}
49+
steps:
50+
- name: Setup crane
51+
uses: imjasonh/setup-crane@v0.4
52+
53+
- name: Login to GHCR
54+
run: crane auth login ghcr.io -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }}
55+
56+
- name: Login to Docker Hub (optional, increases rate limits)
57+
if: ${{ secrets.DOCKERHUB_TOKEN != '' }}
58+
env:
59+
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
60+
run: crane auth login docker.io -u ${{ secrets.DOCKERHUB_USERNAME }} -p $DOCKERHUB_TOKEN
61+
continue-on-error: true
62+
63+
- name: Mirror ${{ matrix.image }}
64+
run: |
65+
SOURCE="docker.io/${{ matrix.image }}"
66+
DEST="ghcr.io/${{ github.repository }}/docker.io/${{ matrix.image }}"
67+
68+
echo "Mirroring: $SOURCE -> $DEST"
69+
70+
# Copy all tags with parallel jobs, overwriting existing tags
71+
# -a: all tags, -j: parallel jobs
72+
crane copy "$SOURCE" "$DEST" --all-tags -j 4

0 commit comments

Comments
 (0)