92 lines
2.3 KiB
YAML
92 lines
2.3 KiB
YAML
name: Deploy to server
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
- beta
|
|
|
|
jobs:
|
|
|
|
deploy-main:
|
|
if: github.ref == 'refs/heads/main'
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Deploy production + demo
|
|
uses: appleboy/ssh-action@v1
|
|
with:
|
|
host: ${{ secrets.SERVER_HOST }}
|
|
username: ${{ secrets.SERVER_USER }}
|
|
key: ${{ secrets.SERVER_SSH_KEY }}
|
|
script: |
|
|
|
|
deploy_force () {
|
|
TARGET=$1
|
|
BRANCH=$2
|
|
|
|
echo "------ Deploying $BRANCH to $TARGET ------"
|
|
|
|
mkdir -p "$TARGET"
|
|
cd "$TARGET"
|
|
|
|
# Si le repo est cassé ou absent → on reclone
|
|
if [ ! -d ".git" ]; then
|
|
echo "Repo absent ou cassé → reclone"
|
|
rm -rf "$TARGET"/*
|
|
git clone https://github.com/Johnnybegood90/GridTV.git .
|
|
fi
|
|
|
|
# Force la branche
|
|
git fetch origin
|
|
|
|
git checkout -B $BRANCH origin/$BRANCH
|
|
|
|
git reset --hard origin/$BRANCH
|
|
git clean -fd
|
|
|
|
echo "Deploy terminé"
|
|
}
|
|
|
|
deploy_force "${{ secrets.DEPLOY_PATH }}" main
|
|
deploy_force "${{ secrets.DEMO_DEPLOY_PATH }}" main
|
|
|
|
|
|
deploy-beta:
|
|
if: github.ref == 'refs/heads/beta'
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Deploy beta
|
|
uses: appleboy/ssh-action@v1
|
|
with:
|
|
host: ${{ secrets.SERVER_HOST }}
|
|
username: ${{ secrets.SERVER_USER }}
|
|
key: ${{ secrets.SERVER_SSH_KEY }}
|
|
script: |
|
|
|
|
deploy_force () {
|
|
TARGET=$1
|
|
BRANCH=$2
|
|
|
|
echo "------ Deploying $BRANCH to $TARGET ------"
|
|
|
|
mkdir -p "$TARGET"
|
|
cd "$TARGET"
|
|
|
|
if [ ! -d ".git" ]; then
|
|
echo "Repo absent ou cassé → reclone"
|
|
rm -rf "$TARGET"/*
|
|
git clone https://github.com/Johnnybegood90/GridTV.git .
|
|
fi
|
|
|
|
git fetch origin
|
|
git checkout -B $BRANCH origin/$BRANCH
|
|
git reset --hard origin/$BRANCH
|
|
git clean -fd
|
|
|
|
echo "Deploy terminé"
|
|
}
|
|
|
|
deploy_force "${{ secrets.BETA_DEPLOY_PATH }}" beta
|