Skip to content

Deploy

Deploy #3

Workflow file for this run

# Sample workflow for building and deploying a Next.js site to GitHub Pages
#
# To get started with Next.js see: https://nextjs.org/docs/getting-started
#
name: Deploy
on:
# Runs on pushes targeting the default branch
# push:
# branches: ["master"]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
# Build job
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "22"
# registry-url: https://registry.npmjs.org/
# cache: ${{ steps.detect-package-manager.outputs.manager }}
- name: Restore cache node_modules
id: cache-dependencies
uses: actions/cache@v4
with:
path: |
**/node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('**/package.json') }}
restore-keys: ${{ runner.os }}-yarn-
- name: Install dependencies
if: steps.cache-dependencies.outputs.cache-hit != 'true'
run: pnpm i
- name: Build ☕️
run: yarn build
- name: Copy Files
run: cp pm2.config.js .next/standalone
- name: Deploy Standalone 🚀
uses: appleboy/scp-action@v0.1.4
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
port: ${{ secrets.PORT }}
source: ".next/standalone/**"
target: ${{ secrets.TARGET }}
strip_components: 2
- name: Deploy Static 🚀
uses: appleboy/scp-action@v0.1.4
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
port: ${{ secrets.PORT }}
source: ".next/static/**"
target: ${{ secrets.TARGET }}
strip_components: 0
# - name: Deploy node_modules 🚀
# if: steps.cache-dependencies.outputs.cache-hit != 'true'
# uses: appleboy/scp-action@v0.1.4
# with:
# host: ${{ secrets.HOST }}
# username: ${{ secrets.USERNAME }}
# key: ${{ secrets.KEY }}
# port: ${{ secrets.PORT }}
# target: ${{ secrets.TARGET }}
# source: "node_modules/**"
# strip_components: 0
- name: Deploy public 🚀
uses: appleboy/scp-action@v0.1.4
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
port: ${{ secrets.PORT }}
target: ${{ secrets.TARGET }}
source: "public/**"
strip_components: 0
- name: Reload Server
uses: appleboy/ssh-action@v1.0.0
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
port: ${{ secrets.PORT }}
script: |
cd ${{ secrets.TARGET }}
PORT=8085 AUTHMAIL=${{ secrets.AUTHMAIL }} AUTHCODE=${{ secrets.AUTHCODE }} pm2 reload pm2.config.js