File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -52,22 +52,18 @@ jobs:
5252 - name : Set up Docker Buildx
5353 uses : docker/setup-buildx-action@v2
5454
55+ - name : Extract tag version
56+ id : tag
57+ run : echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
58+
5559 - name : Log in to Docker Hub
5660 uses : docker/login-action@v2
5761 with :
5862 username : ${{ secrets.DOCKER_USERNAME }}
5963 password : ${{ secrets.DOCKERHUB_TOKEN }}
6064
61- - name : Extract tag version
62- id : tag
63- run : echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
64-
65- - name : Build and push Docker image
66- uses : docker/build-push-action@v4
67- with :
68- context : .
69- file : ./docker/Dockerfile
70- push : true
71- tags : |
72- cchalop1/justdeploy:latest
73- cchalop1/justdeploy:${{ steps.tag.outputs.VERSION }}
65+ - name : Build and push Docker image using script
66+ run : |
67+ cd docker
68+ chmod +x build-docker.sh
69+ ./build-docker.sh --ci
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ FROM alpine:latest
3737
3838WORKDIR /app
3939
40- RUN apk add --no-cache ca-certificates tzdata bash curl docker tar
40+ RUN apk add --no-cache ca-certificates tzdata bash curl docker tar git
4141
4242RUN curl -sSL https://nixpacks.com/install.sh | bash
4343
Original file line number Diff line number Diff line change 33# Variables
44DOCKER_IMAGE=" cchalop1/justdeploy"
55GIT_TAG=$( git describe --tags --abbrev=0 || echo " latest" )
6+ CI_MODE=false
7+
8+ # Check if running in CI mode
9+ if [[ " $1 " == " --ci" ]]; then
10+ CI_MODE=true
11+ fi
612
713# Affiche le message de bienvenue
814echo " ================================"
2834
2935echo " ✅ Construction réussie!"
3036
31- # Demander à l'utilisateur s'il souhaite pousser l'image
37+ # En mode CI, on pousse automatiquement l'image
38+ if [ " $CI_MODE " = true ]; then
39+ echo " 🚀 Mode CI détecté. Envoi de l'image vers Docker Hub..."
40+ docker push $DOCKER_IMAGE :$GIT_TAG
41+ docker push $DOCKER_IMAGE :latest
42+ echo " ✅ Images $DOCKER_IMAGE :$GIT_TAG et $DOCKER_IMAGE :latest poussées avec succès!"
43+ exit 0
44+ fi
45+
46+ # En mode interactif, demander à l'utilisateur
3247read -p " Voulez-vous pousser l'image sur Docker Hub? (o/n): " PUSH_IMAGE
3348
3449if [ " $PUSH_IMAGE " = " o" ] || [ " $PUSH_IMAGE " = " O" ]; then
You can’t perform that action at this time.
0 commit comments