mirror of
https://github.com/arthur-pbty/syncfilm.git
synced 2026-06-03 23:36:38 +02:00
44 lines
1.1 KiB
YAML
44 lines
1.1 KiB
YAML
name: Deploy to VM Prod
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
deploy:
|
|
runs-on: self-hosted
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Deploy to production
|
|
run: |
|
|
REPO_NAME="${{ github.event.repository.name }}"
|
|
ENV_CONTENT="${{ secrets.ENV_FILE || '' }}"
|
|
|
|
ssh ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} bash -s -- "$REPO_NAME" "$ENV_CONTENT" << 'EOF'
|
|
REPO_NAME="$1"
|
|
ENV_CONTENT="$2"
|
|
|
|
mkdir -p /srv/$REPO_NAME
|
|
cd /srv/$REPO_NAME
|
|
|
|
# Supprime tout si le repo n'existe pas encore
|
|
if [ ! -d .git ]; then
|
|
rm -rf ./*
|
|
git clone https://github.com/arthur-pbty-labs/$REPO_NAME .
|
|
else
|
|
git reset --hard
|
|
git pull origin main
|
|
fi
|
|
|
|
# Crée .env seulement si contenu non vide
|
|
if [ -n "$ENV_CONTENT" ]; then
|
|
echo "$ENV_CONTENT" > .env
|
|
fi
|
|
|
|
docker compose up -d --build
|
|
EOF
|