Created
January 6, 2024 03:26
-
-
Save garyblankenship/0df6dd646b71afa95bf0f522ad7f7575 to your computer and use it in GitHub Desktop.
Workflow to Deploy Laravel to Digital Ocean
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 characters
name: Deploy to DigitalOcean | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up PHP | |
uses: shivammathur/setup-php@master | |
with: | |
php-version: '8.2' | |
extensions: mbstring, ctype, fileinfo, openssl, pdo, bcmath, json, tokenizer, xml | |
- name: Cache Composer Dependencies | |
uses: actions/cache@v3 | |
with: | |
path: ~/.composer/cache | |
key: composer-${{ hashFiles('composer.json') }} | |
restore-keys: composer- | |
- name: Install Composer dependencies | |
run: composer install --no-dev --no-interaction --prefer-dist | |
- name: Cache Node.js Packages | |
uses: actions/cache@v3 | |
with: | |
path: ~/.npm | |
key: npm-${{ hashFiles('package-lock.json') }} | |
restore-keys: npm- | |
- name: Install Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '18' | |
- name: Build assets | |
run: | | |
npm install | |
npm run build | |
- name: Upload Build Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: laravel-artifact | |
path: . | |
deploy-to-server: | |
needs: deploy | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download Build Artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: laravel-artifact | |
path: default | |
- name: Transfer Artifact to Server | |
uses: appleboy/scp-action@master | |
with: | |
host: ${{ secrets.SERVER_IP }} | |
username: ${{ secrets.SERVER_USER }} | |
key: ${{ secrets.SERVER_KEY }} | |
password: ${{ secrets.SERVER_PASSWORD }} | |
port: ${{ secrets.SERVER_PORT }} | |
source: "default/*" | |
target: "/home/forge" | |
- name: Unpack Artifact and Deploy | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.SERVER_IP }} | |
username: ${{ secrets.SERVER_USER }} | |
key: ${{ secrets.SERVER_KEY }} | |
password: ${{ secrets.SERVER_PASSWORD }} | |
port: ${{ secrets.SERVER_PORT }} | |
script: | | |
cd /home/forge/default | |
composer install --no-dev --no-interaction --prefer-dist | |
php artisan migrate --force | |
php artisan optimize | |
php artisan filament:upgrade |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment