mirror of
https://github.com/arthur-pbty/links.git
synced 2026-08-01 20:29:27 +02:00
Amélioration du script de déploiement : ajout de la gestion dynamique du nom du dépôt et mise à jour du chemin de déploiement
This commit is contained in:
@@ -3,24 +3,40 @@ name: Deploy to VM Prod
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main # déclenche le déploiement quand tu push sur main
|
- main
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
deploy:
|
deploy:
|
||||||
runs-on: self-hosted # ton runner VM code-server
|
runs-on: self-hosted
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Deploy to production
|
- name: Deploy to production
|
||||||
run: |
|
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 }} "
|
ssh ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} "
|
||||||
mkdir -p ${{ secrets.DEPLOY_PATH }}
|
mkdir -p /srv/$REPO_NAME
|
||||||
cd ${{ secrets.DEPLOY_PATH }}
|
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
|
if [ ! -d .git ]; then
|
||||||
git clone https://github.com/arthur-pbty/links .
|
git clone https://github.com/arthur-pbty-labs/$REPO_NAME .
|
||||||
else
|
else
|
||||||
git pull origin main
|
git pull origin main
|
||||||
fi
|
fi
|
||||||
|
|
||||||
docker compose up -d --build
|
docker compose up -d --build
|
||||||
"
|
"
|
||||||
|
|||||||
Reference in New Issue
Block a user