Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 9 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@ on:
branches:
- develop
- main
workflow_dispatch:
inputs:
branch:
description: 'Branch to deploy'
required: true
default: 'main'
push:
branches:
- main # pour que PROD puisse se déclencher automatiquement si besoin

jobs:
# 1️⃣ Build & tests
Expand Down Expand Up @@ -45,7 +42,6 @@ jobs:
- name: Build app
run: pnpm build


# 2️⃣ Build & push Docker image
docker-build-push:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -88,8 +84,7 @@ jobs:
build-args: |
NEXT_PUBLIC_ENV=${{ github.base_ref }}


# 3️⃣ Deploy DEV
# 3️⃣ Deploy DEV (auto sur PR)
deploy-dev:
runs-on: self-hosted
needs: docker-build-push
Expand All @@ -108,19 +103,20 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Pull new image + restart stack
- name: Pull new image + restart DEV stack
run: |
echo "🔧 Deploying on the server..."
echo "🔧 Deploying on DEV..."
cd /home/baptiste/Dev/WPT/dev
docker-compose pull
docker rm -f wpt-dev_website || true
docker-compose up -d --remove-orphans
echo "🚀 Deployed in DEV!"

# 4️⃣ Deploy PROD (skip par défaut, relançable sur main)
deploy-prod:
runs-on: self-hosted
needs: docker-build-push
if: ${{ github.event.inputs.branch == 'main' }}
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
steps:
- name: Clean workspace
run: rm -rf *
Expand All @@ -137,7 +133,7 @@ jobs:

- name: Pull new image + restart PROD stack
run: |
echo "🔧 Deploying on the server (PROD)..."
echo "🔧 Deploying on PROD..."
cd /home/baptiste/Dev/WPT/prod
docker-compose pull
docker rm -f wpt_website || true
Expand Down
Loading