Skip to content

Commit

Permalink
refactor(deploy): simplify and clean up deploy workflow
Browse files Browse the repository at this point in the history
Reduced steps and streamlined tasks in the GitHub Actions deploy workflow to optimize the deployment process. Updated comments and naming conventions for better clarity.
  • Loading branch information
frederic moras committed Dec 25, 2024
1 parent e866c00 commit 74b9711
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 29 deletions.
40 changes: 12 additions & 28 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,52 +1,35 @@
name: Deploy Application
name: Deploy to Server

on:
push:
branches:
- main
- main # Déclencher l'action sur les push vers la branche main

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout code
# 1. Vérifier le dépôt
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up SSH
# 2. Configurer SSH
- name: Setup SSH
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}"
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
cat ~/.ssh/id_rsa
ssh-keyscan -H 207.154.255.72 >> ~/.ssh/known_hosts
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
extensions: mbstring, bcmath, ctype, fileinfo, json, tokenizer, xml, pdo_mysql

- name: Install Composer dependencies
run: composer install --no-dev --optimize-autoloader

- name: Test SSH Connection
# 3. Déployer sur le serveur
- name: Deploy application
run: |
ssh -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa [email protected] echo "SSH connection successful"
- name: Deploy using SSH
uses: appleboy/[email protected]
with:
host: 207.154.255.72
username: root
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: 22
script: |
ssh -o StrictHostKeyChecking=no [email protected] << 'EOF'
cd /var/www/laravel
git fetch origin
git checkout main
git pull origin main
# Ajouter des commandes spécifiques pour votre application
npm install
composer install --no-dev --optimize-autoloader
php artisan migrate --force
php artisan config:cache
Expand All @@ -56,6 +39,7 @@ jobs:
chmod -R 775 storage bootstrap/cache
php artisan queue:restart
php artisan cache:clear
EOF
- name: Notify Deployment Success
run: echo "Deployment completed successfully!"
2 changes: 1 addition & 1 deletion resources/views/home.blade.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@extends('Layouts.app')

@section('title')
Acceuil
Boom Acceuil
@endsection

@section('content')
Expand Down

0 comments on commit 74b9711

Please sign in to comment.