Skip to content

Commit

Permalink
fix: Correction du path du dockerfile, ajout de la variable target po…
Browse files Browse the repository at this point in the history
…ur choisir l'image que l'on souhaite build -> par default prod
  • Loading branch information
David-IGN committed Oct 14, 2024
1 parent 5956063 commit fb1afce
Showing 1 changed file with 11 additions and 22 deletions.
33 changes: 11 additions & 22 deletions .github/workflows/docker-publish.yaml
Original file line number Diff line number Diff line change
@@ -1,30 +1,23 @@
name: Docker

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

on:
#schedule:
# - cron: '40 18 * * *'
workflow_dispatch:
inputs:
target:
description: 'Build target (prod or dev)'
required: true
default: 'prod'

push:
branches: [ "main" ]
# Publish semver tags as releases.
tags: [ 'v*.*.*' ]
pull_request:
branches: [ "main" ]

env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}


jobs:
build:

runs-on: ubuntu-latest
permissions:
contents: read
Expand All @@ -34,12 +27,9 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3

# Workaround: https://github.com/docker/build-push-action/issues/461
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v2

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
Expand All @@ -48,24 +38,23 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v3
with:
context: .
file: ./docker/Dockerfile
file: .docker/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: # Spécifier l'argument pour passer le mode de build
TARGET: ${{ github.event.inputs.target }}
target: ${{ github.event.inputs.target }} # Dev ou Prod
cache-from: type=gha
cache-to: type=gha,mode=max

0 comments on commit fb1afce

Please sign in to comment.