-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
08dc574
commit 8988fb4
Showing
4 changed files
with
126 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,86 @@ | ||
name: 😊 Deploiment - Laravel CD | ||
name: 😊 Deploiment - InstaRepas | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: 'Numéro de version pour le déploiement (format: X.Y.Z)' | ||
required: false | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
|
||
steps: | ||
- name: 📦 Récupération du Code | ||
uses: actions/[email protected] | ||
uses: actions/[email protected] | ||
with: | ||
fetch-depth: '0' | ||
|
||
- name: ⚙️ Configuration de PHP | ||
uses: shivammathur/setup-php@2.25.4 | ||
uses: shivammathur/setup-php@2.30.4 | ||
with: | ||
php-version: '8.2' | ||
extensions: bcmath, bz2, calendar, Core, ctype, curl, date, dom, exif, FFI, fileinfo, filter, ftp, gd, gettext, hash, iconv, igbinary, imagick, imap, intl, json, libxml, mbstring, mcrypt, mysqli, mysqlnd, openssl, pcntl, pcre, PDO, pdo_mysql, Phar, posix, readline, redis, Reflection, session, shmop, SimpleXML, soap, sockets, sodium, SPL, standard, sysvmsg, sysvsem, sysvshm, tokenizer, xml, xmlreader, xmlrpc, xmlwriter, xsl, zip, zlib, Zend OPcache | ||
php-version: '8.3' | ||
extensions: mongodb, bcmath, bz2, calendar, Core, ctype, curl, date, dom, exif, FFI, fileinfo, filter, ftp, gd, gettext, hash, iconv, igbinary, imagick, imap, intl, json, libxml, mbstring, mcrypt, mysqli, mysqlnd, openssl, pcntl, pcre, PDO, pdo_mysql, Phar, posix, readline, redis, Reflection, session, shmop, SimpleXML, soap, sockets, sodium, SPL, standard, sysvmsg, sysvsem, sysvshm, tokenizer, xml, xmlreader, xmlrpc, xmlwriter, xsl, zip, zlib, Zend OPcache | ||
tools: composer:v2 | ||
|
||
- name: 📚 Installation de NPM | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y npm | ||
npm --version | ||
- name: 🚀 Aller au répertoire Laravel et afficher | ||
run: | | ||
cd InstaRepas | ||
pwd | ||
ls -la | ||
- name: 🛠️ Installation des dépendances du projet | ||
run: | | ||
composer install --no-progress --prefer-dist --optimize-autoloader | ||
composer install --no-dev --no-progress --prefer-dist --optimize-autoloader | ||
npm install | ||
working-directory: ./InstaRepas | ||
- name: 🏗️ Construction du Projet | ||
run: | | ||
npm run build | ||
working-directory: ./InstaRepas | ||
- name: 🗝️ Ajouter la clé SSH | ||
run: | | ||
mkdir -p ~/.ssh | ||
echo "${{ secrets.SSH_KNOWN_HOSTS }}" >> ~/.ssh/known_hosts | ||
- name: 🔐 Configuration de SSH et rsync | ||
uses: webfactory/ssh-agent@v0.8.0 | ||
uses: webfactory/ssh-agent@v0.9.0 | ||
with: | ||
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} | ||
|
||
- name: 🚀 Déployer sur le serveur | ||
- name: 🏷️ Création du tag de version | ||
uses: anothrNick/github-tag-action@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
CUSTOM_TAG: ${{ github.event.inputs.version }} | ||
WITH_V: true | ||
|
||
- name: 🗑️ Supprimer les répertoires bootstrap/cache, public et storage | ||
run: | | ||
rsync -r -avz -O --delete-after --exclude=.git --exclude=.github --exclude=dist --exclude=node_modules --exclude=.env --quiet -e 'ssh -p ${{ secrets.REMOTE_PORT }}' ${{ secrets.REMOTE_PATH }} $GITHUB_WORKSPACE/InstaRepas/ ${{ secrets.REMOTE_USER }}@${{ secrets.REMOTE_HOST }}:${{ secrets.REMOTE_DIR }} | ||
- name: 🔄 Changer les permissions de /storage et bootstrap/cache | ||
ssh -p ${{ secrets.REMOTE_PORT }} ${{ secrets.REMOTE_USER }}@${{ secrets.REMOTE_HOST }} "sudo rm -rf ${{ secrets.PROD_DIR }}/bootstrap/ ${{ secrets.PROD_DIR }}/public ${{ secrets.PROD_DIR }}/storage" | ||
- name: 🚀 Déploiement sur le serveur de production | ||
run: | | ||
ssh -p ${{ secrets.REMOTE_PORT }} ${{ secrets.REMOTE_USER }}@${{ secrets.REMOTE_HOST }} "${{ secrets.REMOTE_OWN }} ${{ secrets.REMOTE_DIR }}/storage" | ||
ssh -p ${{ secrets.REMOTE_PORT }} ${{ secrets.REMOTE_USER }}@${{ secrets.REMOTE_HOST }} "${{ secrets.REMOTE_OWN }} ${{ secrets.REMOTE_DIR }}/bootstrap/cache" | ||
ssh -p ${{ secrets.REMOTE_PORT }} ${{ secrets.REMOTE_USER }}@${{ secrets.REMOTE_HOST }} "${{ secrets.REMOTE_MOD }} ${{ secrets.REMOTE_DIR }}/storage" | ||
ssh -p ${{ secrets.REMOTE_PORT }} ${{ secrets.REMOTE_USER }}@${{ secrets.REMOTE_HOST }} "${{ secrets.REMOTE_MOD }} ${{ secrets.REMOTE_DIR }}/bootstrap/cache" | ||
ssh -p ${{ secrets.REMOTE_PORT }} ${{ secrets.REMOTE_USER }}@${{ secrets.REMOTE_HOST }} "${{ secrets.REMOTE_WWW }} ${{ secrets.REMOTE_DIR }}/public" | ||
- name: 🔑 Copie du fichier .env si absent | ||
echo "Répertoire de travail local :" | ||
pwd | ||
echo "Contenu du répertoire de travail local :" | ||
ls -la | ||
echo "Déploiement des fichiers vers le serveur de production..." | ||
rsync -r -avz -O --delete-after --exclude=kubernetes --exclude=database --exclude=install.sh --exclude=conf --exclude=.github --exclude=.editorconfig --exclude=dist --exclude=node_modules --exclude=.env --exclude=Dockerfile --exclude=_ide_helper.php --exclude=_ide_helper_models.php --exclude=shell-php.nix --exclude=shell-stripe.nix --exclude=php.nix --exclude=deploy.yaml --exclude=README.md --exclude=tests --exclude=.phpstorm.meta.php --exclude=.env.example --exclude=phpunit.xml --exclude=.gitattributes --exclude=.git --exclude=.gitignore --quiet -e 'ssh -p ${{ secrets.REMOTE_PORT }}' . ${{ secrets.REMOTE_USER }}@${{ secrets.REMOTE_HOST }}:${{ secrets.PROD_DIR }} | ||
- name: 🔄 Changer le propriétaire et les permissions des répertoires | ||
run: | | ||
ssh -p ${{ secrets.REMOTE_PORT }} ${{ secrets.REMOTE_USER }}@${{ secrets.REMOTE_HOST }} "if [ ! -f ${{ secrets.REMOTE_DIR }}/.env ]; then cp ${{ secrets.REMOTE_DIR }}/.env.example ${{ secrets.REMOTE_DIR }}/.env; fi" | ||
- name: 🔄 Générer la clé Laravel si nécessaire | ||
ssh -p ${{ secrets.REMOTE_PORT }} ${{ secrets.REMOTE_USER }}@${{ secrets.REMOTE_HOST }} "sudo chown -R www-data:www-data ${{ secrets.PROD_DIR }}/bootstrap/cache ${{ secrets.PROD_DIR }}/public ${{ secrets.PROD_DIR }}/storage" | ||
ssh -p ${{ secrets.REMOTE_PORT }} ${{ secrets.REMOTE_USER }}@${{ secrets.REMOTE_HOST }} "sudo chmod -R 775 ${{ secrets.PROD_DIR }}/bootstrap/cache ${{ secrets.PROD_DIR }}/storage" | ||
- name: 🎨 Exécuter les commandes de maintenance Laravel | ||
run: | | ||
ssh -p ${{ secrets.REMOTE_PORT }} ${{ secrets.REMOTE_USER }}@${{ secrets.REMOTE_HOST }} "if grep -q 'APP_KEY=' ${{ secrets.REMOTE_DIR }}/.env && grep -q '^APP_KEY=$' ${{ secrets.REMOTE_DIR }}/.env; then cd ${{ secrets.REMOTE_DIR }} && php artisan key:generate; fi" | ||
ssh -p ${{ secrets.REMOTE_PORT }} ${{ secrets.REMOTE_USER }}@${{ secrets.REMOTE_HOST }} "cd ${{ secrets.PROD_DIR }} && sudo php artisan cache:clear && sudo php artisan route:clear && sudo php artisan view:clear" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
name: 🔄 Rollback Deployment | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
tag_to_deploy: | ||
description: 'Tag Git à déployer' | ||
required: true | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
|
||
steps: | ||
- name: Récupération du code source | ||
uses: actions/[email protected] | ||
with: | ||
ref: ${{ github.event.inputs.tag_to_deploy }} | ||
fetch-depth: 0 | ||
|
||
- name: ⚙️ Configuration de PHP | ||
uses: shivammathur/[email protected] | ||
with: | ||
php-version: '8.3' | ||
extensions: mongodb, bcmath, bz2, calendar, Core, ctype, curl, date, dom, exif, FFI, fileinfo, filter, ftp, gd, gettext, hash, iconv, igbinary, imagick, imap, intl, json, libxml, mbstring, mcrypt, mysqli, mysqlnd, openssl, pcntl, pcre, PDO, pdo_mysql, Phar, posix, readline, redis, Reflection, session, shmop, SimpleXML, soap, sockets, sodium, SPL, standard, sysvmsg, sysvsem, sysvshm, tokenizer, xml, xmlreader, xmlrpc, xmlwriter, xsl, zip, zlib, Zend OPcache | ||
tools: composer:v2 | ||
|
||
- name: 📚 Installation de NPM | ||
run: | | ||
sudo apt-get install -y npm | ||
npm --version | ||
- name: 🚀 Aller au répertoire Laravel et afficher | ||
run: | | ||
pwd | ||
ls -la | ||
- name: 🛠️ Installation des dépendances du projet | ||
run: | | ||
composer install --no-dev --no-progress --prefer-dist --optimize-autoloader | ||
npm install | ||
- name: 🏗️ Construction du Projet | ||
run: | | ||
npm run build | ||
- name: 🗝️ Ajouter la clé SSH | ||
run: | | ||
mkdir -p ~/.ssh | ||
echo "${{ secrets.SSH_KNOWN_HOSTS }}" >> ~/.ssh/known_hosts | ||
- name: 🔐 Configuration de SSH et rsync | ||
uses: webfactory/[email protected] | ||
with: | ||
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} | ||
|
||
- name: 🗑️ Supprimer les répertoires bootstrap/cache, public et storage | ||
run: | | ||
ssh -p ${{ secrets.REMOTE_PORT }} ${{ secrets.REMOTE_USER }}@${{ secrets.REMOTE_HOST }} "sudo rm -rf ${{ secrets.PROD_DIR }}/bootstrap/ ${{ secrets.PROD_DIR }}/public ${{ secrets.PROD_DIR }}/storage" | ||
- name: 🚀 Déploiement sur le serveur de production | ||
run: | | ||
echo "Répertoire de travail local :" | ||
pwd | ||
echo "Contenu du répertoire de travail local :" | ||
ls -la | ||
echo "Déploiement des fichiers vers le serveur de production..." | ||
rsync -r -avz -O --delete-after --exclude=kubernetes --exclude=install.sh --exclude=database --exclude=conf --exclude=.github --exclude=.editorconfig --exclude=dist --exclude=node_modules --exclude=.env --exclude=Dockerfile --exclude=_ide_helper.php --exclude=_ide_helper_models.php --exclude=shell-php.nix --exclude=shell-stripe.nix --exclude=php.nix --exclude=deploy.yaml --exclude=README.md --exclude=tests --exclude=.phpstorm.meta.php --exclude=.env.example --exclude=phpunit.xml --exclude=.gitattributes --exclude=.git --exclude=.gitignore --quiet -e 'ssh -p ${{ secrets.REMOTE_PORT }}' . ${{ secrets.REMOTE_USER }}@${{ secrets.REMOTE_HOST }}:${{ secrets.PROD_DIR }} | ||
- name: 🔄 Changer le propriétaire et les permissions des répertoires | ||
run: | | ||
ssh -p ${{ secrets.REMOTE_PORT }} ${{ secrets.REMOTE_USER }}@${{ secrets.REMOTE_HOST }} "sudo chown -R www-data:www-data ${{ secrets.PROD_DIR }}/bootstrap/cache ${{ secrets.PROD_DIR }}/public ${{ secrets.PROD_DIR }}/storage" | ||
ssh -p ${{ secrets.REMOTE_PORT }} ${{ secrets.REMOTE_USER }}@${{ secrets.REMOTE_HOST }} "sudo chmod -R 775 ${{ secrets.PROD_DIR }}/bootstrap/cache ${{ secrets.PROD_DIR }}/storage" | ||
- name: 🎨 Exécuter les commandes de maintenance Laravel | ||
run: | | ||
ssh -p ${{ secrets.REMOTE_PORT }} ${{ secrets.REMOTE_USER }}@${{ secrets.REMOTE_HOST }} "cd ${{ secrets.PROD_DIR }} && sudo php artisan cache:clear && sudo php artisan route:clear && sudo php artisan view:clear" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters