From 6ae9db4735da1b577036add55ff35872032878b4 Mon Sep 17 00:00:00 2001 From: Arthur Date: Sat, 13 Sep 2025 22:13:41 +0200 Subject: [PATCH] =?UTF-8?q?Am=C3=A9liorer=20le=20workflow=20de=20d=C3=A9pl?= =?UTF-8?q?oiement=20en=20ajoutant=20la=20gestion=20du=20contenu=20du=20fi?= =?UTF-8?q?chier=20.env=20et=20en=20corrigeant=20le=20chemin=20de=20d?= =?UTF-8?q?=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, 18 insertions(+), 8 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 2e321e5..c0b1d3f 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -7,26 +7,36 @@ on: jobs: deploy: - runs-on: self-hosted + runs-on: self-hosted steps: - name: Checkout repository uses: actions/checkout@v3 - name: Deploy to production run: | - ssh ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} " - mkdir -p ${{ secrets.DEPLOY_PATH }} - cd ${{ secrets.DEPLOY_PATH }} + REPO_NAME=${{ github.event.repository.name }} - echo '${{ secrets.ENV_FILE }}' > .env + # 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 /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/syncfilm . + git clone https://github.com/arthur-pbty-labs/$REPO_NAME . else git pull origin main fi docker compose up -d --build " - -