Skip to content

Instantly share code, notes, and snippets.

@tarikmanoar
Last active April 9, 2025 03:34
Show Gist options
  • Select an option

  • Save tarikmanoar/b1d8a0b51d19851c975166a7d468f421 to your computer and use it in GitHub Desktop.

Select an option

Save tarikmanoar/b1d8a0b51d19851c975166a7d468f421 to your computer and use it in GitHub Desktop.
This gist help you to deploy laravel application from github to your server using ssh
name: CI/CD with GitHub Actions
on:
push:
branches: [master]
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
- name: Install Composer dependencies
run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '*'
- name: Install NPM dependencies
run: npm install
- name: Build assets with Vite
run: npm run build
- name: Copy repository contents via SCP ==MANOAR==
uses: appleboy/scp-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
port: ${{ secrets.PORT }}
password: ${{ secrets.PASSWORD }}
source: "*,!.git"
target: ${{ secrets.DIR }}
verbose: false
- name: Executing remote commands
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
port: ${{ secrets.PORT }}
password: ${{ secrets.PASSWORD }}
script: |
cd ${{ secrets.DIR }}
php artisan migrate --force
php artisan config:cache
php artisan route:cache
php artisan view:cache
php artisan storage:link
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment