Compare commits

17 Commits

Author SHA1 Message Date
cedric b025ed2256 deploy: use node for healthcheck
Déploiement API BETA / Tests extensions (push) Successful in 11m8s
Déploiement API BETA / Build et déploiement beta (push) Successful in 47s
2026-05-15 22:15:35 +04:00
cedric 2fbe1a1e4d deploy: use docker healthcheck
Déploiement API BETA / Tests extensions (push) Successful in 11m7s
Déploiement API BETA / Build et déploiement beta (push) Failing after 3m6s
2026-05-15 21:59:01 +04:00
cedric 8f6a0bb85a deploy: use sudo tp change ownership
Déploiement API BETA / Tests extensions (push) Successful in 11m5s
Déploiement API BETA / Build et déploiement beta (push) Successful in 50s
2026-05-15 19:21:20 +04:00
cedric f3b01adc5f deploy: change file permission
Déploiement API BETA / Tests extensions (push) Successful in 11m4s
Déploiement API BETA / Build et déploiement beta (push) Failing after 36s
2026-05-15 18:53:52 +04:00
cedric 35aa06b33b fix: change directus port 2026-05-15 18:53:35 +04:00
cedric a5bb2cb35c deploy: add logs for debug
Déploiement API BETA / Tests extensions (push) Successful in 11m5s
Déploiement API BETA / Build et déploiement beta (push) Failing after 1m59s
2026-05-15 18:33:54 +04:00
cedric 409c32a207 deploy: check directus network
Déploiement API BETA / Tests extensions (push) Successful in 11m8s
Déploiement API BETA / Build et déploiement beta (push) Failing after 1m36s
2026-05-15 18:13:55 +04:00
cedric 6878f1a291 deploy: change health check
Déploiement API BETA / Tests extensions (push) Successful in 11m5s
Déploiement API BETA / Build et déploiement beta (push) Failing after 36s
2026-05-15 18:00:22 +04:00
cedric 9f364bf677 deploy: fix directus port
Déploiement API BETA / Tests extensions (push) Successful in 11m7s
Déploiement API BETA / Build et déploiement beta (push) Failing after 1m35s
2026-05-15 17:38:23 +04:00
cedric 6600a22475 deploy: fix directus access
Déploiement API BETA / Tests extensions (push) Successful in 11m7s
Déploiement API BETA / Build et déploiement beta (push) Failing after 1m30s
2026-05-15 17:00:23 +04:00
cedric 23e20a0015 deploy: change permission
Déploiement API BETA / Tests extensions (push) Successful in 11m7s
Déploiement API BETA / Build et déploiement beta (push) Failing after 43s
2026-05-15 16:43:54 +04:00
cedric 10f3062779 deploy: use sudo to use git
Déploiement API BETA / Tests extensions (push) Successful in 11m5s
Déploiement API BETA / Build et déploiement beta (push) Failing after 35s
2026-05-15 15:45:07 +04:00
cedric f978cad3f6 deploy: sync branche
Déploiement API BETA / Tests extensions (push) Successful in 11m6s
Déploiement API BETA / Build et déploiement beta (push) Failing after 35s
2026-05-15 14:40:34 +04:00
cedric b88f7deb43 deploy: simplify deployment
Déploiement API BETA / Tests extensions (push) Successful in 11m5s
Déploiement API BETA / Build et déploiement beta (push) Failing after 35s
2026-05-15 14:26:56 +04:00
cedric e6ead4e700 chore: remove dist from .gitignore 2026-05-15 14:26:40 +04:00
cedric ba7beabb36 deploy: merge build & deploy steps
Déploiement API BETA / Tests extensions (push) Successful in 11m6s
Déploiement API BETA / Build et déploiement beta (push) Failing after 32s
2026-05-15 14:10:19 +04:00
cedric 54672ecac3 deploy: replce ci by install in test
Déploiement API BETA / Tests extensions (push) Successful in 11m7s
Déploiement API BETA / Build extensions (push) Failing after 45s
Déploiement API BETA / Déploiement beta (push) Has been skipped
2026-05-15 13:56:41 +04:00
6 changed files with 38 additions and 49 deletions
+29 -46
View File
@@ -18,13 +18,13 @@ jobs:
cache: 'npm' cache: 'npm'
- name: Installer les dépendances - name: Installer les dépendances
run: npm ci run: npm install
- name: Lancer les tests - name: Lancer les tests
run: npm test run: npm test
build: build-and-deploy:
name: Build extensions name: Build et déploiement beta
needs: test needs: test
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
@@ -42,46 +42,16 @@ jobs:
working-directory: extensions/directus-extension-new-user working-directory: extensions/directus-extension-new-user
run: npm install && npm run build run: npm install && npm run build
- name: Uploader les artefacts de build - name: Committer et pousser les dist
uses: actions/upload-artifact@v4
with:
name: extensions-dist
path: |
extensions/directus-extension-disallow-votes/dist
extensions/directus-extension-new-user/dist
retention-days: 1
deploy:
name: Déploiement beta
needs: build
runs-on: ubuntu-latest
steps:
- name: Télécharger les artefacts de build
uses: actions/download-artifact@v4
with:
name: extensions-dist
path: dist-artifacts
- name: Configurer la clé SSH
run: | run: |
mkdir -p ~/.ssh git config user.name "Gitea Actions"
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/deploy_key git config user.email "actions@noreply.gitea"
chmod 600 ~/.ssh/deploy_key git add extensions/directus-extension-disallow-votes/dist \
ssh-keyscan -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_HOST }} >> ~/.ssh/known_hosts extensions/directus-extension-new-user/dist
git diff --staged --quiet || git commit -m "chore: build extensions [skip ci]"
git push origin dev
- name: Transférer les dist via rsync - name: Déployer sur le serveur
run: |
rsync -az --delete \
-e "ssh -i ~/.ssh/deploy_key -p ${{ secrets.SSH_PORT }}" \
dist-artifacts/extensions/directus-extension-disallow-votes/dist/ \
${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:${{ secrets.DEPLOY_PATH }}/extensions/directus-extension-disallow-votes/dist/
rsync -az --delete \
-e "ssh -i ~/.ssh/deploy_key -p ${{ secrets.SSH_PORT }}" \
dist-artifacts/extensions/directus-extension-new-user/dist/ \
${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:${{ secrets.DEPLOY_PATH }}/extensions/directus-extension-new-user/dist/
- name: Redémarrer Directus et vérifier
uses: appleboy/ssh-action@v1.2.0 uses: appleboy/ssh-action@v1.2.0
with: with:
host: ${{ secrets.SSH_HOST }} host: ${{ secrets.SSH_HOST }}
@@ -92,10 +62,23 @@ jobs:
set -e set -e
cd ${{ secrets.DEPLOY_PATH }} cd ${{ secrets.DEPLOY_PATH }}
echo "==> Redémarrage Directus" echo "==> Correction des permissions"
docker compose restart directus sudo chown -R "$(whoami):" .
echo "==> Vérification santé" echo "==> Synchronisation branche dev"
sleep 5 git fetch origin dev
curl -sf http://localhost:8066/server/health | grep -q '"status":"ok"' git reset --hard origin/dev
echo "==> Réseau Docker"
docker network inspect konstitisyon_network >/dev/null 2>&1 \
|| docker network create konstitisyon_network
echo "==> Initialisation base de données"
[ -f database/data.db ] || cp database/data.sample.db database/data.db
echo "==> Permissions volumes"
sudo chown -R 1000:1000 database uploads
echo "==> Démarrage Directus"
docker compose up -d --wait
echo "Déploiement OK" echo "Déploiement OK"
+7 -1
View File
@@ -2,12 +2,18 @@ services:
directus: directus:
image: directus/directus:11.17.2 image: directus/directus:11.17.2
ports: ports:
- 8066:8066 - 8066:8055
volumes: volumes:
- ./database:/directus/database - ./database:/directus/database
- ./uploads:/directus/uploads - ./uploads:/directus/uploads
- ./extensions:/directus/extensions - ./extensions:/directus/extensions
env_file: ".env" env_file: ".env"
healthcheck:
test: ["CMD-SHELL", "node -e \"require('http').get('http://localhost:8055/server/health',r=>process.exit(r.statusCode<400?0:1)).on('error',()=>process.exit(1))\""]
interval: 10s
timeout: 5s
retries: 12
start_period: 30s
networks: networks:
- konstitisyon_network - konstitisyon_network
networks: networks:
@@ -1,3 +1,2 @@
.DS_Store .DS_Store
node_modules node_modules
dist
@@ -0,0 +1 @@
var e=({filter:e},{services:t})=>{const s=async(e,s,o)=>{if(!e)throw new Error("Lidentifiant de la version est manquant.");const n=await s("directus_versions").select("date_created").where({id:e}).first();if(!n)throw new Error("Version non trouvée.");if(new Date(n.date_created)<new Date(Date.now()-2592e5))throw new Error("Le vote nest plus possible après 3 jours de la création de la version.");try{const{VersionsService:n}=t,r=new n({schema:o,knex:s}),a=await r.compare(e);if(a&&!0===a.outdated)throw new Error("Le vote nest plus possible sur une version obsolète.")}catch(e){if("Le vote nest plus possible sur une version obsolète."===e.message)throw e;console.warn("Could not check version outdated status:",e.message)}};e("items.create",(async(e,{collection:t},{database:o,schema:n})=>("votes"===t&&await s(e.content_version_id,o,n),e))),e("items.update",(async(e,{collection:t},{database:o,schema:n})=>("votes"===t&&await s(e.content_version_id,o,n),e))),e("items.delete",(async(e,{collection:t},{database:o,schema:n})=>{if("votes"===t){const t=e[0];if(!t)throw new Error("Lidentifiant du vote est manquant.");const r=await o("votes").select("content_version_id").where({id:t}).first();if(!r)throw new Error("Vote non trouvé.");await s(r.content_version_id,o,n)}return e}))};export{e as default};
@@ -1,3 +1,2 @@
.DS_Store .DS_Store
node_modules node_modules
dist
+1
View File
@@ -0,0 +1 @@
var e=({filter:e},{services:r,env:a})=>{e("users.create",(async(e,{schema:i},{database:s})=>{if(!r.MailService)return console.error("Le service MailService est manquant."),e;const t=a.EMAIL_NEW_USER,n=a.DIRECTUS_URL||"http://0.0.0.0:8055";if(!t)return console.error("La variable EMAIL_NEW_USER est manquante."),e;const l=await(async(e,r)=>void 0!==await r("directus_users").select("id").where({email:e}).first())(e.email,s);if(l)return console.error("Ladresse e-mail est déjà utilisée."),e;try{new r.MailService({schema:i}).send({to:t,subject:`Nouvel utilisateur : ${e.email}`,text:`Un nouvel utilisateur a été créé :\n Nom: ${e.first_name||"N/A"} Email: ${e.email||"N/A"}\n Pour valider => ${n}/admin/users`,html:`\n <p>Un nouvel utilisateur a été créé :</p>\n <ul>\n <li><strong>Nom:</strong> ${e.first_name||"N/A"} </li>\n <li><strong>Email:</strong> ${e.email||"N/A"}</li>\n </ul>\n <p>Pour valider, <a href="${n}/admin/users" target="_blank"><strong>cliquez ici</strong></a> ou sur ce lien => <a href="${n}/admin/users" target="_blank">${n}/admin/users</a></p>\n `}),console.log("Email envoyé avec succès à",t)}catch(e){console.error("Erreur lors de lenvoi de le-mail via MailService:",e)}return e}))};export{e as default};