From 4c90116ef761629a16dfd42233bc61dd0e6a6740 Mon Sep 17 00:00:00 2001 From: Arthur Date: Sat, 13 Sep 2025 22:13:31 +0200 Subject: [PATCH] =?UTF-8?q?Am=C3=A9lioration=20du=20script=20de=20d=C3=A9p?= =?UTF-8?q?loiement=20:=20ajout=20de=20la=20gestion=20dynamique=20du=20nom?= =?UTF-8?q?=20du=20d=C3=A9p=C3=B4t=20et=20mise=20=C3=A0=20jour=20du=20chem?= =?UTF-8?q?in=20de=20d=C3=A9ploiement?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yml | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index bccc7ab..c0b1d3f 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -3,24 +3,40 @@ name: Deploy to VM Prod on: push: branches: - - main # déclenche le déploiement quand tu push sur main + - main jobs: deploy: - runs-on: self-hosted # ton runner VM code-server + runs-on: self-hosted steps: - name: Checkout repository uses: actions/checkout@v3 - name: Deploy to production run: | + REPO_NAME=${{ github.event.repository.name }} + + # Préparer le contenu du .env (vide si secret non défini) + if [ -z "${{ secrets.ENV_FILE }}" ]; then + ENV_CONTENT="" + else + ENV_CONTENT="${{ secrets.ENV_FILE }}" + fi + ssh ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} " - mkdir -p ${{ secrets.DEPLOY_PATH }} - cd ${{ secrets.DEPLOY_PATH }} + mkdir -p /srv/$REPO_NAME + cd /srv/$REPO_NAME + + # Crée .env seulement si contenu non vide + if [ -n \"$ENV_CONTENT\" ]; then + echo \"$ENV_CONTENT\" > .env + fi + if [ ! -d .git ]; then - git clone https://github.com/arthur-pbty/links . + git clone https://github.com/arthur-pbty-labs/$REPO_NAME . else git pull origin main fi + docker compose up -d --build "