Skip to content
This repository has been archived by the owner on Jul 15, 2024. It is now read-only.

chore: use corepack #57

chore: use corepack

chore: use corepack #57

Workflow file for this run

name: Deploy Next.js App
on:
push:
branches:
- main
env:
pm2Version: 5.4.1
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Setup Nodejs
uses: actions/[email protected]
with:
node-version: 20
- run: node -v
- run: corepack enable pnpm
- run: corepack install
- run: pnpm -v
- run: pnpm install --frozen-lockfile
- run: pnpm test -- --run
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Setup Nodejs
uses: actions/[email protected]
with:
node-version: 20
- run: node -v
- run: corepack enable pnpm
- run: corepack install
- run: pnpm -v
- run: pnpm install --frozen-lockfile
- run: pnpm run build
deploy:
env:
repo: https://github.com/${{ github.repository }}
branch: main
dir: /home/nextjs-large-file-upload
runs-on: ubuntu-latest
steps:
- name: Use the environment secret
run: echo ${{ secrets.VPS_HOST }}
- name: Use the default environment variables
run: echo ${{ env.branch }} ${{ env.repo }} ${{ env.dir }}
- name: Deploy to VPS
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.VPS_HOST }}
username: ${{ secrets.VPS_USER }}
key: ${{ secrets.VPS_SSH_KEY }}
port: ${{ secrets.VPS_PORT }}
script: |
node -v
# git reset
mkdir -p ${{ env.dir }}
cd ${{ env.dir }}
git init
git remote add origin ${{ env.repo }}
git fetch --all
git reset --hard origin/${{ env.branch }}
# install depencencies
corepack enable pnpm
corepack install
pnpm -v
pnpm install --frozen-lockfile
# start pm2
pnpm run build
npm install -g pm2@${{ env.pm2Version }}
pm2 start
pm2 ls
pm2 logs --lines 10 --nostream