Update main.yml #2
This file contains 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: Build and Deploy | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest # 构建环境使用 ubuntu | |
steps: | |
- name: Checkout code # 将代码拉到虚拟机 | |
uses: actions/checkout@v2 | |
- name: Setup Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '18.18.0' | |
- name: Setup pnpm | |
uses: pnpm/[email protected] | |
with: | |
version: 8.12.0 | |
- name: Install dependencies | |
run: pnpm install | |
- name: Build Next.js app | |
run: pnpm build | |
- name: Deploy to Custom Server | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.SERVER_HOST }} # 服务器IP或域名 | |
username: ${{ secrets.SERVER_USERNAME }} # 服务器用户名 | |
key: ${{ secrets.SERVER_SSH_KEY }} # 服务器SSH私钥 | |
script: | | |
cd /home/project/blog-web | |
git pull origin master | |
pnpm install --production | |
pm2 restart app |