Compare commits
32 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
14342999e2 | ||
|
|
0e18715f05 | ||
|
|
b64fa8fada | ||
|
|
932c500c1b | ||
|
|
72d52577e3 | ||
|
|
3919254309 | ||
|
|
b4f2bb4e33 | ||
|
|
75a3c7febb | ||
|
|
735bdfe856 | ||
|
|
f1b0885a30 | ||
|
|
7ef43a29cb | ||
|
|
3f6dddcd0a | ||
|
|
a2512b1cca | ||
|
|
bcee6b5514 | ||
|
|
11f0109bc5 | ||
|
|
e25080a87c | ||
|
|
f71058a31a | ||
|
|
bd98d8eb6e | ||
|
|
e684cadb9f | ||
|
|
0c091538e8 | ||
|
|
ccda246266 | ||
|
|
6a55acd235 | ||
|
|
faecd90037 | ||
|
|
680ac2fd2b | ||
|
|
3d7f20d2bf | ||
|
|
7df04c4084 | ||
|
|
ed5ffdbdc0 | ||
|
|
f6e52f7420 | ||
|
|
35adae3978 | ||
|
|
161e2c12cf | ||
|
|
d20a29408f | ||
|
|
78e682d10f |
@@ -3,9 +3,11 @@ when:
|
||||
branch: [ main ]
|
||||
|
||||
variables:
|
||||
- &node_image node:18-alpine
|
||||
- &git_image alpine/git
|
||||
- &curl_image curlimages/curl:latest
|
||||
node_image: &node_image node:18-alpine
|
||||
git_image: &git_image alpine/git
|
||||
curl_image: &curl_image curlimages/curl:latest
|
||||
nexus_api: &nexus_api http://nexus.cicd.exygen.fr/service/rest/v1
|
||||
woodpecker_api: &woodpecker_api http://woodpecker.cicd.exygen.fr/api
|
||||
|
||||
steps:
|
||||
# Étape 1: Nettoyage du projet
|
||||
@@ -105,6 +107,7 @@ steps:
|
||||
NEXUS_PASSWORD:
|
||||
from_secret: nexus_password
|
||||
NEXUS_REPOSITORY: domaine-passignat
|
||||
NEXUS_API: *nexus_api
|
||||
commands: |
|
||||
source $CI_WORKSPACE/version.env
|
||||
|
||||
@@ -120,8 +123,7 @@ steps:
|
||||
-u "$NEXUS_USERNAME:$NEXUS_PASSWORD" \
|
||||
-F "raw.directory=apps/$CI_REPO_NAME/$NEW_VERSION" \
|
||||
-F "raw.asset1=@$ARTIFACT_FILE" \
|
||||
-F "raw.asset1.filename=$ARTIFACT" \
|
||||
http://nexus.cicd.exygen.fr/service/rest/v1/components?repository=$NEXUS_REPOSITORY
|
||||
-F "raw.asset1.filename=$ARTIFACT" $NEXUS_API/components?repository=$NEXUS_REPOSITORY
|
||||
echo "✅ Artefact publié"
|
||||
else
|
||||
echo "⏭️ Pas de publication (version_type=none)"
|
||||
@@ -136,7 +138,7 @@ steps:
|
||||
from_secret: gitea_token
|
||||
commands: |
|
||||
source $CI_WORKSPACE/version.env
|
||||
|
||||
|
||||
if [ "$version_type" != "none" ]; then
|
||||
git remote set-url origin http://oauth2:$GITEA_TOKEN@gitea.cicd.exygen.fr/$CI_REPO_OWNER/$CI_REPO_NAME.git
|
||||
git config user.email "woodpecker@exygen.fr"
|
||||
@@ -178,6 +180,7 @@ steps:
|
||||
- name: trigger-deployment
|
||||
image: curlimages/curl:latest
|
||||
environment:
|
||||
WOODPECKER_API: *woodpecker_api
|
||||
WOODPECKER_TOKEN:
|
||||
from_secret: woodpecker_token
|
||||
commands: |
|
||||
@@ -186,9 +189,8 @@ steps:
|
||||
echo "🚀 Déclenchement du déploiement pour la version $NEW_VERSION"
|
||||
echo "🚀 $CI_REPO_OWNER"
|
||||
echo "🚀 $CI_REPO_NAME"
|
||||
echo "http://woodpecker.cicd.exygen.fr/api/repos/$CI_REPO_OWNER/$CI_REPO_NAME/pipelines"
|
||||
curl -v --fail -X POST \
|
||||
"http://woodpecker.cicd.exygen.fr/api/repos/$CI_REPO_OWNER/$CI_REPO_NAME/pipelines" \
|
||||
echo "$WOODPECKER_API/repos/$CI_REPO_OWNER/$CI_REPO_NAME/pipelines"
|
||||
curl -v --fail -X POST "$WOODPECKER_API/repos/$CI_REPO_OWNER/$CI_REPO_NAME/pipelines" \
|
||||
-H "Authorization: Bearer $WOODPECKER_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
|
||||
@@ -2,27 +2,40 @@
|
||||
|
||||
when:
|
||||
- event: [ deployment,manual ]
|
||||
variables:
|
||||
minio_mc: &minio_mc minio/mc
|
||||
appleboy_drone_scp: &appleboy_drone_scp appleboy/drone-scp
|
||||
appleboy_drone_ssh: &appleboy_drone_ssh appleboy/drone-ssh
|
||||
curlimages_curl: &curlimages_curl curlimages/curl:latest
|
||||
nexus_url: &nexus_url http://nexus.cicd.exygen.fr/repository/domaine-passignat/apps
|
||||
|
||||
|
||||
steps:
|
||||
- name: share-data
|
||||
image: minio/mc
|
||||
- name: get-share-data
|
||||
image: *minio_mc
|
||||
commands:
|
||||
- echo "ℹ️ Save pipeline info"
|
||||
- echo NEW_VERSION=$NEW_VERSION > .buildinfo
|
||||
- echo "ℹ️ Load pipeline info"
|
||||
- mc alias set local http://minio:9000 minioadmin minioadmin123
|
||||
- mc get local/cicd/repository_$CI_REPO_REMOTE_ID/pipeline_$CI_PIPELINE_PARENT .buildinfo
|
||||
- ls -als
|
||||
|
||||
- name: get-artifact
|
||||
image: curlimages/curl:latest
|
||||
commands: |
|
||||
source .buildinfo
|
||||
echo new version: ${NEW_VERSION}
|
||||
curl -o /tmp/${CI_REPO_NAME}-${NEW_VERSION}.tar \
|
||||
"https://nexus.cicd.exygen.fr/repository/domaine-passignat/apps/${CI_REPO_NAME}/${NEW_VERSION}/${CI_REPO_NAME}-${VERSION}.tar"
|
||||
image: *curlimages_curl
|
||||
environment:
|
||||
NEXUS_USERNAME:
|
||||
from_secret: nexus_username
|
||||
NEXUS_PASSWORD:
|
||||
from_secret: nexus_password
|
||||
NEXUS_REPOSITORY: domaine-passignat
|
||||
NEXUS_URL: *nexus_url
|
||||
commands:
|
||||
- ls -als
|
||||
- curl -o /tmp/${CI_REPO_NAME}-${NEW_VERSION}.tar "${NEXUS_URL}/${CI_REPO_NAME}/${NEW_VERSION}/${CI_REPO_NAME}-${NEW_VERSION}.tar"
|
||||
depends_on: [ get-share-data ]
|
||||
|
||||
# Étape 7: Transfert vers le serveur distant (SCP)
|
||||
- name: transfert
|
||||
image: appleboy/drone-scp
|
||||
image: *appleboy_drone_scp
|
||||
settings:
|
||||
host:
|
||||
from_secret: remote_host
|
||||
@@ -33,11 +46,11 @@ steps:
|
||||
port: 22
|
||||
source: /tmp/${CI_REPO_NAME}-${NEW_VERSION}.tar
|
||||
target: /tmp/
|
||||
depends_on: [ get-artifact ,share-data]
|
||||
depends_on: [ get-artifact ]
|
||||
|
||||
# Étape 8: Déploiement sur le serveur distant
|
||||
- name: deploy
|
||||
image: appleboy/drone-ssh
|
||||
image: *appleboy_drone_ssh
|
||||
environment:
|
||||
SUDO_PASSWORD:
|
||||
from_secret: remote_password
|
||||
@@ -52,19 +65,20 @@ steps:
|
||||
envs:
|
||||
- SUDO_PASSWORD
|
||||
script:
|
||||
- source .buildinfo
|
||||
- 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/${CI_REPO_NAME}-${NEW_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
|
||||
- rm -f /tmp/${CI_REPO_NAME}-${NEW_VERSION}.tar
|
||||
- docker-compose up database
|
||||
- cd /srv/volumes/gestion/tmpdb
|
||||
- npm ci --cache .npm --prefer-offline
|
||||
|
||||
1
database/src/sql/version-0.0.42-0.0.43.sql
Normal file
1
database/src/sql/version-0.0.42-0.0.43.sql
Normal file
@@ -0,0 +1 @@
|
||||
-- none
|
||||
1
database/src/sql/version-0.0.43-0.0.44.sql
Normal file
1
database/src/sql/version-0.0.43-0.0.44.sql
Normal file
@@ -0,0 +1 @@
|
||||
-- none
|
||||
1
database/src/sql/version-0.0.44-0.0.45.sql
Normal file
1
database/src/sql/version-0.0.44-0.0.45.sql
Normal file
@@ -0,0 +1 @@
|
||||
-- none
|
||||
1
database/src/sql/version-0.0.45-0.0.46.sql
Normal file
1
database/src/sql/version-0.0.45-0.0.46.sql
Normal file
@@ -0,0 +1 @@
|
||||
-- none
|
||||
1
database/src/sql/version-0.0.46-0.0.47.sql
Normal file
1
database/src/sql/version-0.0.46-0.0.47.sql
Normal file
@@ -0,0 +1 @@
|
||||
-- none
|
||||
1
database/src/sql/version-0.0.47-0.0.48.sql
Normal file
1
database/src/sql/version-0.0.47-0.0.48.sql
Normal file
@@ -0,0 +1 @@
|
||||
-- none
|
||||
1
database/src/sql/version-0.0.48-0.0.49.sql
Normal file
1
database/src/sql/version-0.0.48-0.0.49.sql
Normal file
@@ -0,0 +1 @@
|
||||
-- none
|
||||
1
database/src/sql/version-0.0.49-0.0.50.sql
Normal file
1
database/src/sql/version-0.0.49-0.0.50.sql
Normal file
@@ -0,0 +1 @@
|
||||
-- none
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "cicd",
|
||||
"private": true,
|
||||
"version": "0.0.42",
|
||||
"version": "0.0.50",
|
||||
"description": "Node.js Rest Apis with Express, Sequelize & PostgreSQL",
|
||||
"scripts": {
|
||||
"update:patch": "node scripts/update-version.js -patch",
|
||||
|
||||
Reference in New Issue
Block a user