Skip to content

update

update #2

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: Build and Deploy SSR
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@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: "18"
# cache: ${{ steps.detect-package-manager.outputs.manager }}
- name: Restore cache node_modules
id: cache-dependencies
uses: actions/cache@v3
with:
path: |
**/node_modules
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package.json') }}
- name: Install dependencies
if: steps.cache-dependencies.outputs.cache-hit != 'true'
run: yarn
- name: Build ☕️
run: yarn build
- name: Copy Files
run: |
cp pm2.config.js .next
cp -r .next/static .next/standalone/.next
- 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: Deploy SSR 🚀
uses: appleboy/scp-action@v0.1.4
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
port: ${{ secrets.PORT }}
source: ".next/standalone/**,.next/package.json,.next/pm2.config.js"
target: ${{ secrets.TARGET }}
strip_components: 1
- name: Reload SSR
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