Skip to content

Commit 8c316d6

Browse files
committed
chore: update justdeploy-release workflow to use build-docker.sh script for CI mode and modify Dockerfile to include git
1 parent 68116cb commit 8c316d6

3 files changed

Lines changed: 26 additions & 15 deletions

File tree

.github/workflows/justdeploy-release.yml

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff 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

docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ FROM alpine:latest
3737

3838
WORKDIR /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

4242
RUN curl -sSL https://nixpacks.com/install.sh | bash
4343

docker/build-docker.sh

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
# Variables
44
DOCKER_IMAGE="cchalop1/justdeploy"
55
GIT_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
814
echo "================================"
@@ -28,7 +34,16 @@ fi
2834

2935
echo "✅ 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
3247
read -p "Voulez-vous pousser l'image sur Docker Hub? (o/n): " PUSH_IMAGE
3348

3449
if [ "$PUSH_IMAGE" = "o" ] || [ "$PUSH_IMAGE" = "O" ]; then

0 commit comments

Comments
 (0)