Skip to content

Commit

Permalink
fix: Déclenchement du build seulement en manuel
Browse files Browse the repository at this point in the history
  • Loading branch information
David-IGN committed Oct 15, 2024
1 parent 125b6a1 commit d77b3f8
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions .github/workflows/docker-publish.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
on:

push:
branches: [ "main" ]
tags: [ 'v*.*.*' ]
pull_request:
branches: [ "main" ]
workflow_dispatch:
inputs:
version:
description: 'Version tag (e.g., v1.0.0)'
required: true
default: 'v1.0.0'

env:
REGISTRY: ghcr.io
Expand All @@ -18,14 +18,21 @@ jobs:
packages: write

steps:
- name: Validate version input
id: validate_version
run: |
if [[ ! "${{ github.event.inputs.version }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Error: Version must follow the format vX.X.X"
exit 1
fi
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup Docker buildx
uses: docker/setup-buildx-action@v2

- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
Expand All @@ -37,17 +44,17 @@ jobs:
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: ${{ github.event.inputs.version }}

- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v3
with:
context: .
file: .docker/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
target: 'prod' # Cible le stage (prod)
cache-from: type=gha
cache-to: type=gha,mode=max

0 comments on commit d77b3f8

Please sign in to comment.