Last active
April 9, 2025 03:34
-
-
Save tarikmanoar/b1d8a0b51d19851c975166a7d468f421 to your computer and use it in GitHub Desktop.
Revisions
-
tarikmanoar revised this gist
Apr 9, 2025 . 1 changed file with 50 additions and 19 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,48 +1,71 @@ name: 🎉 Laravel Deploy on: push: branches: [master] workflow_dispatch: # Allow manual triggering jobs: deploy: runs-on: ubuntu-latest steps: - name: 📦 Checkout code uses: actions/checkout@v4 - name: ⚙️ Setup PHP uses: shivammathur/setup-php@v2 with: php-version: '8.3' extensions: mbstring, xml, ctype, iconv, intl, pdo_mysql, bcmath, zip, curl, fileinfo, tokenizer, dom, json, exif, gd, imagick, mysqli, redis, sodium, pgsql, sqlite3 coverage: none - name: 🧰 Setup Node.js uses: actions/setup-node@v3 with: node-version: 'lts/*' cache: 'npm' - name: ♻️ Cache Composer dependencies id: composer-cache uses: actions/cache@v3 with: path: vendor key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} restore-keys: ${{ runner.os }}-composer- - name: 🧩 Install Composer dependencies run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader - name: Run PHP Code Style (Pint) run: vendor/bin/pint - name: ♻️ Cache NPM dependencies id: npm-cache uses: actions/cache@v3 with: path: node_modules key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} restore-keys: ${{ runner.os }}-node- - name: 📥 Install NPM dependencies run: npm ci - name: 🔨 Build frontend assets run: npm run build - name: 🚀 Upload to server via SCP uses: appleboy/scp-action@master with: host: ${{ secrets.HOST }} username: ${{ secrets.USERNAME }} port: ${{ secrets.PORT }} password: ${{ secrets.PASSWORD }} source: ".,!.git,!.github,!node_modules,!tests,!storage/framework/testing,!.env,!.vscode,!.idea" target: ${{ secrets.DIR }} strip_components: 0 - name: 🛠️ Run deployment commands uses: appleboy/ssh-action@master with: host: ${{ secrets.HOST }} @@ -51,8 +74,16 @@ jobs: password: ${{ secrets.PASSWORD }} script: | cd ${{ secrets.DIR }} php artisan down --retry=60 php artisan migrate --force php artisan optimize:clear php artisan optimize php artisan storage:link # Verify deployment succeeded if php artisan --version > /dev/null; then php artisan up echo "Deployment successful!" else echo "Deployment failed, site remains in maintenance mode" exit 1 fi -
tarikmanoar created this gist
Nov 18, 2024 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,58 @@ 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