Skip to content

Commit 24f5299

Browse files
feat: dockerhub sync images workflow
1 parent 25c8a2e commit 24f5299

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Sync DockerHub images to GHCR
2+
3+
on:
4+
workflow_dispatch: # Permet de lancer manuellement
5+
schedule:
6+
- cron: '0 0 * * 0' # Exécution hebdomadaire le dimanche à minuit
7+
8+
jobs:
9+
sync-images:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
packages: write
13+
contents: read
14+
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
19+
#- name: Login to DockerHub
20+
# uses: docker/login-action@v3
21+
# with:
22+
# username: ${{ secrets.DOCKERHUB_USERNAME }}
23+
# password: ${{ secrets.DOCKERHUB_TOKEN }}
24+
25+
- name: Login to GHCR
26+
uses: docker/login-action@v3
27+
with:
28+
registry: ghcr.io
29+
username: ${{ github.repository_owner }}
30+
password: ${{ secrets.GITHUB_TOKEN }}
31+
32+
- name: Sync Images
33+
env:
34+
IMAGES: |
35+
ollama/ollama
36+
traefik:v3.2
37+
run: |
38+
# Lecture de la liste des images
39+
echo "$IMAGES" | while read image; do
40+
if [ ! -z "$image" ]; then
41+
echo "Processing $image"
42+
43+
# Pull de l'image depuis DockerHub
44+
docker pull "$image"
45+
46+
# Préparation du nom pour GHCR
47+
GHCR_IMAGE="ghcr.io/${GITHUB_REPOSITORY}/${image}"
48+
49+
# Tag pour GHCR
50+
docker tag "$image" "$GHCR_IMAGE"
51+
52+
# Push vers GHCR
53+
docker push "$GHCR_IMAGE"
54+
55+
echo "Successfully synced $image to $GHCR_IMAGE"
56+
fi
57+
done

0 commit comments

Comments
 (0)