Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 61 additions & 43 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,61 @@
name: Build and Deploy Next.js Static Site to Lightsail

on:
push:
branches: [main]

jobs:
build-and-deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install dependencies
run: npm ci

- name: Build and export static site
run: npm run export

- name: Upload static site to server
uses: appleboy/scp-action@v0.1.4
with:
host: ${{ secrets.LIGHTSAIL_HOST }}
username: ${{ secrets.LIGHTSAIL_USER }}
key: ${{ secrets.LIGHTSAIL_SSH_KEY }}
source: "out/*"
target: "/var/www/davidpdonohue.com/html"
strip_components: 1

- name: Reload Nginx
uses: appleboy/ssh-action@v0.1.10
with:
host: ${{ secrets.LIGHTSAIL_HOST }}
username: ${{ secrets.LIGHTSAIL_USER }}
key: ${{ secrets.LIGHTSAIL_SSH_KEY }}
script: |
sudo systemctl reload nginx
name: Build and Deploy Next.js Static Site to Lightsail

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
build-and-deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'

- name: Clear npm cache
run: npm cache clean --force

- name: Install dependencies
run: npm ci --legacy-peer-deps

- name: Run type checking
run: npm run type-check

- name: Run linting
run: npm run lint

- name: Run tests
run: npm run test:ci

- name: Build and export static site
run: npm run export

- name: Upload static site to server
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
uses: appleboy/scp-action@v0.1.4
with:
host: ${{ secrets.LIGHTSAIL_HOST }}
username: ${{ secrets.LIGHTSAIL_USER }}
key: ${{ secrets.LIGHTSAIL_SSH_KEY }}
source: "out/*"
target: "/var/www/davidpdonohue.com/html"
strip_components: 1

- name: Reload Nginx
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
uses: appleboy/ssh-action@v0.1.10
with:
host: ${{ secrets.LIGHTSAIL_HOST }}
username: ${{ secrets.LIGHTSAIL_USER }}
key: ${{ secrets.LIGHTSAIL_SSH_KEY }}
script: |
sudo systemctl reload nginx
sudo systemctl status nginx
Loading