File tree Expand file tree Collapse file tree 1 file changed +57
-0
lines changed Expand file tree Collapse file tree 1 file changed +57
-0
lines changed Original file line number Diff line number Diff line change
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
You can’t perform that action at this time.
0 commit comments