This commit is contained in:
64
.woodpecker/deploy-pipeline.yml
Normal file
64
.woodpecker/deploy-pipeline.yml
Normal file
@@ -0,0 +1,64 @@
|
||||
# Documentation: https://woodpecker-ci.org/docs/usage/workflow-syntax
|
||||
|
||||
when:
|
||||
- event: deployment
|
||||
|
||||
steps:
|
||||
- name: get-artifact
|
||||
image: curlimages/curl:latest
|
||||
commands: |
|
||||
VERSION=${CI_COMMIT_TAG#v}
|
||||
curl -o /tmp/${CI_REPO_NAME}-${VERSION}.tar \
|
||||
"https://nexus.cicd.exygen.fr/repository/domaine-passignat/apps/${CI_REPO_NAME}/${VERSION}/${CI_REPO_NAME}-${VERSION}.tar"
|
||||
|
||||
# Étape 7: Transfert vers le serveur distant (SCP)
|
||||
- name: transfert
|
||||
image: appleboy/drone-scp
|
||||
settings:
|
||||
host:
|
||||
from_secret: remote_host
|
||||
username:
|
||||
from_secret: remote_user
|
||||
password:
|
||||
from_secret: remote_password
|
||||
port: 22
|
||||
source: /tmp/${CI_REPO_NAME}-${VERSION}.tar
|
||||
target: /tmp/
|
||||
depends_on: [ get-artifact ]
|
||||
|
||||
# Étape 8: Déploiement sur le serveur distant
|
||||
- name: deploy
|
||||
image: appleboy/drone-ssh
|
||||
environment:
|
||||
SUDO_PASSWORD:
|
||||
from_secret: remote_password
|
||||
settings:
|
||||
host:
|
||||
from_secret: remote_host
|
||||
username:
|
||||
from_secret: remote_user
|
||||
password:
|
||||
from_secret: remote_password
|
||||
port: 22
|
||||
envs:
|
||||
- SUDO_PASSWORD
|
||||
script:
|
||||
- echo "$${SUDO_PASSWORD}" | sudo -S systemctl stop gestion
|
||||
- mkdir -p /srv/volumes/gestion/{front-binaries,back-binaries,tmpdb}
|
||||
- rm -rf /srv/volumes/gestion/front-binaries/*
|
||||
- rm -rf /srv/volumes/gestion/back-binaries/*
|
||||
- rm -rf /srv/volumes/gestion/tmpdb/*
|
||||
- tar -xvf /tmp/${CI_REPO_NAME}-${VERSION}.tar -C /tmp
|
||||
- tar -xvf /tmp/front.tar.gz -C /srv/volumes/gestion/front-binaries
|
||||
- tar -xzvf /tmp/back.tar.gz -C /srv/volumes/gestion/back-binaries
|
||||
- tar -xzvf /tmp/db.tar.gz -C /srv/volumes/gestion/tmpdb
|
||||
- rm -f /tmp/front.tar.gz
|
||||
- rm -f /tmp/back.tar.gz
|
||||
- rm -f /tmp/db.tar.gz
|
||||
- rm -f /tmp/${CI_REPO_NAME}-${VERSION}.tar
|
||||
- docker-compose up database
|
||||
- cd /srv/volumes/gestion/tmpdb
|
||||
- npm ci --cache .npm --prefer-offline
|
||||
- npm run install-db
|
||||
- echo "$${SUDO_PASSWORD}" | sudo -S systemctl start gestion
|
||||
depends_on: [ transfert ]
|
||||
Reference in New Issue
Block a user