92 lines
2.8 KiB
YAML
92 lines
2.8 KiB
YAML
name: Déploiement AEGIS Portal
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- dev
|
|
- test
|
|
- acc
|
|
- master
|
|
|
|
jobs:
|
|
build-and-deploy:
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
GIT_SSL_NO_VERIFY: "true"
|
|
NODE_TLS_REJECT_UNAUTHORIZED: "0"
|
|
|
|
steps:
|
|
- name: Patch DNS local pour Gitea Runner
|
|
run: sudo echo "10.10.40.31 git.bunker.lan" | sudo tee -a /etc/hosts
|
|
|
|
- name: Configuration de Git pour SSL
|
|
run: git config --global http.sslVerify false
|
|
|
|
- name: Récupération du code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Configuration de Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 22
|
|
|
|
- name: Configuration de Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 22
|
|
|
|
- name: Activation de pnpm
|
|
run: corepack enable pnpm
|
|
|
|
- name: Installation des dépendances
|
|
run: pnpm install --frozen-lockfile
|
|
|
|
- name: Compilation de la Build
|
|
env:
|
|
VITE_APP_ENV: ${{ github.ref_name }}
|
|
run: pnpm run build
|
|
|
|
- name: Installation de lftp
|
|
run: sudo apt-get update && sudo apt-get install -y lftp
|
|
|
|
- name: Routage et Déploiement FTP
|
|
env: # 1. On charge tous les secrets de manière sécurisée
|
|
SERVER: ${{ secrets.FTP_SERVER }}
|
|
DEV_U: ${{ secrets.DEV_FTP_USER }}
|
|
DEV_P: ${{ secrets.DEV_FTP_PASSWORD }}
|
|
TEST_U: ${{ secrets.TEST_FTP_USER }}
|
|
TEST_P: ${{ secrets.TEST_FTP_PASSWORD }}
|
|
ACC_U: ${{ secrets.ACC_FTP_USER }}
|
|
ACC_P: ${{ secrets.ACC_FTP_PASSWORD }}
|
|
PROD_U: ${{ secrets.PROD_FTP_USER }}
|
|
PROD_P: ${{ secrets.PROD_FTP_PASSWORD }}
|
|
BRANCH: ${{ github.ref_name }}
|
|
run: |
|
|
# 2. On attribue les bons identifiants selon la branche
|
|
if [ "$BRANCH" == "master" ]; then
|
|
TARGET_USER=$PROD_U; TARGET_PASS=$PROD_P;
|
|
elif [ "$BRANCH" == "acc" ]; then
|
|
TARGET_USER=$ACC_U; TARGET_PASS=$ACC_P;
|
|
elif [ "$BRANCH" == "test" ]; then
|
|
TARGET_USER=$TEST_U; TARGET_PASS=$TEST_P;
|
|
else
|
|
TARGET_USER=$DEV_U; TARGET_PASS=$DEV_P;
|
|
fi
|
|
|
|
echo "Déploiement de la branche [$BRANCH]"
|
|
|
|
# 3. Exécution du script FTP
|
|
cat << EOF > script.lftp
|
|
set ftp:passive-mode true
|
|
set ftp:ssl-allow no
|
|
set ssl:verify-certificate no
|
|
set net:timeout 5
|
|
set net:max-retries 2
|
|
set dns:fatal-timeout 2
|
|
open -u "${TARGET_USER}","${TARGET_PASS}" "${SERVER}"
|
|
cd home/${TARGET_USER}
|
|
mirror -R --delete --verbose dist/ ./
|
|
quit
|
|
EOF
|
|
|
|
lftp -f script.lftp |