diff --git a/.aspell.fr.pws b/.aspell.fr.pws index c846697..1b9aca2 100644 --- a/.aspell.fr.pws +++ b/.aspell.fr.pws @@ -1,4 +1,4 @@ -personal_ws-1.1 fr 196 +personal_ws-1.1 fr 209 AVAX Aborted Add @@ -30,6 +30,7 @@ Frame GB GJ GPU +Gandi Geth Gio Git @@ -38,6 +39,7 @@ Gmail Gogs HDMI HTTP +Host ICUSB IMAP IP @@ -85,6 +87,7 @@ Rabby Raspberry Raspbian Rpi +SFTP SSH SVG Server @@ -115,6 +118,7 @@ WebSocket Wi-Fi Windows Working +YAML ZIP Zsh account-pwd.txt @@ -131,10 +135,14 @@ configurateur copiez-le cronjob debug +deploy +deploy.yml dev double-cliquez débogage email +error +failed favicon fork frame @@ -142,17 +150,20 @@ framework from func genesis +git hash htdocs identifiants infos inverter +key keystore l'URL l'Utilisateur l'audio l'onduleur learn +lftp libpng logs luma @@ -190,8 +201,10 @@ t télécharger vCPU validator +verification web window work worker +workflow xxx diff --git a/checks.sh b/checks.sh index d713a55..eb2c9c5 100755 --- a/checks.sh +++ b/checks.sh @@ -42,10 +42,20 @@ check_spelling_files() { check_spelling_file 'README.md' } +check_yaml_file() { + yamllint -d relaxed "${1}" +} + +check_yaml_files() { + check_yaml_file "${FOLDER}" + check_yaml_file '.github' +} + main() { check_python_files check_shell_files check_markdown_files + check_yaml_files check_spelling_files } diff --git a/requirements-tests.txt b/requirements-tests.txt index 5519b0e..d6e403c 100644 --- a/requirements-tests.txt +++ b/requirements-tests.txt @@ -3,3 +3,4 @@ mypy==1.8.0 pymarkdownlnt==0.9.16 ruff==0.2.0 sphinx-autobuild==2021.3.14 +yamllint==1.33.0 diff --git a/sources/linux/github-deploiement-vers-gandi.md b/sources/linux/github-deploiement-vers-gandi.md new file mode 100644 index 0000000..c46137d --- /dev/null +++ b/sources/linux/github-deploiement-vers-gandi.md @@ -0,0 +1,75 @@ +# GitHub : Déployer un site web vers Gandi + +Gandi permet de déployer un site web via git ou SFTP. Voyons comment automatiser le déploiement via SFTP. + +## Prérequis + +Nous utiliserons [lftp](https://lftp.yar.ru/lftp-man.html) pour l'envoi des fichiers : + +```{literalinclude} snippets/github-deploiement-vers-gandi.sh + :lines: 3 + :language: shell +``` + +## Manuel + +Pas directement lié à GitHub, ces étapes peuvent servir à déployer depuis n'importe quelle machine. + +### Constantes + +D'abord, nous aurons besoin de définir ces constantes : + +```{literalinclude} snippets/github-deploiement-vers-gandi.sh + :lines: 5-8 + :language: shell +``` + +### âš ï¸ Approuver la Connexion + +```{hint} +Bien que nécessaire, cette étape est à ne faire qu'une seule fois par machine. +``` + +Approuver la connexion au serveur pour éviter l'erreur "*Fatal error: Host key verification failed*" : + +```{literalinclude} snippets/github-deploiement-vers-gandi.sh + :lines: 10-11 + :language: shell +``` + +### Répliquer + +Voici la dernière étape qui permet de faire un miroir d'un dossier local vers un dossier distant (remplacer `FOLDER` par le dossier local) : + +```{literalinclude} snippets/github-deploiement-vers-gandi.sh + :lines: 13-16 + :emphasize-lines: 2 + :language: shell +``` + +## Automatisation + +Maintenant que les étapes sont connues, nous utiliserons un *workflow* GitHub pour déployer le site à chaque changement poussé sur la branche principale du dépôt. + +### Secrets + +Dans les paramètres du dépôt GitHub, déclarer 4 secrets identiques aux [constantes](#constantes) déclarées plus haut. + +### *Workflow* + +Voici le script YAML complet : + +```{literalinclude} snippets/github-deploiement-vers-gandi.yml + :caption: .github/workflows/deploy.yml + :emphasize-lines: 6,25 + :language: yaml +``` + +### Exemple Complet + +Un exemple spécifique à Python, utilisé par ce site même, peut être visible par ici : [BoboTiG/luma:deploy](https://github.com/BoboTiG/luma/blob/main/.github/workflows/deploy.yml). + +## 📜 Historique + +2024-02-04 +: Premier jet. diff --git a/sources/linux/snippets/github-deploiement-vers-gandi.sh b/sources/linux/snippets/github-deploiement-vers-gandi.sh new file mode 100644 index 0000000..6381808 --- /dev/null +++ b/sources/linux/snippets/github-deploiement-vers-gandi.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +sudo apt install lftp + +SFTP_URL='HOST' +SFTP_USER='USERNAME' +SFTP_PASSWORD='PASSWORD' +SFTP_PATH='/mnt/vhost/site/subfolder/' + +mkdir -p ~/.ssh \ + && ssh-keyscan -H "${SFTP_URL}" >> ~/.ssh/known_hosts + +lftp \ + -e "mirror --delete --transfer-all --reverse --verbose=1 ./FOLDER ${SFTP_PATH} ; quit" \ + -u "${SFTP_USER},${SFTP_PASSWORD}" \ + "sftp://${SFTP_URL}" diff --git a/sources/linux/snippets/github-deploiement-vers-gandi.yml b/sources/linux/snippets/github-deploiement-vers-gandi.yml new file mode 100644 index 0000000..ae765d3 --- /dev/null +++ b/sources/linux/snippets/github-deploiement-vers-gandi.yml @@ -0,0 +1,27 @@ +name: Deploy + +on: + push: + branches: + - main + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install dependencies + run: sudo apt install -y lftp + + - name: Setup SSH + run: | + mkdir -p ~/.ssh + ssh-keyscan -H ${{ secrets.SFTP_URL }} >> ~/.ssh/known_hosts + + - name: Automation + run: | + lftp \ + -e 'mirror --delete --transfer-all --reverse --verbose=1 ./FOLDER ${{ secrets.SFTP_PATH }} ; quit' \ + -u '${{ secrets.SFTP_USER }},${{ secrets.SFTP_PASSWORD }}' \ + 'sftp://${{ secrets.SFTP_URL }}'