feat: 完成日期 map 获取 #26
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 | |
steps: | |
- name: Checkout # 拉取仓库内容 | |
if: ${{ contains(github.event.head_commit.message, 'build-and-deploy') }} | |
uses: actions/checkout@v4 | |
- name: Setup pnpm # 安装 pnpm | |
if: ${{ contains(github.event.head_commit.message, 'build-and-deploy') }} | |
uses: pnpm/action-setup@v4 | |
with: | |
version: 9 | |
- name: Use Node.js 20 # 使用 Node.js 20 | |
if: ${{ contains(github.event.head_commit.message, 'build-and-deploy') }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: pnpm | |
- name: Install dependencies with pnpm # 使用 pnpm 安装依赖 | |
if: ${{ contains(github.event.head_commit.message, 'build-and-deploy') }} | |
run: pnpm install --frozen-lockfile | |
- name: Build the project # 构建项目 | |
if: ${{ contains(github.event.head_commit.message, 'build-and-deploy') }} | |
run: pnpm build | |
- name: Compress output # 打包构建结果 | |
if: ${{ contains(github.event.head_commit.message, 'build-and-deploy') }} | |
run: tar -zcvf nuxt.tar.gz .output | |
- name: Copy files to server # 上传压缩包到服务器 | |
if: ${{ contains(github.event.head_commit.message, 'build-and-deploy') }} | |
uses: appleboy/scp-action@v0.1.7 | |
with: | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USERNAME }} | |
key: ${{ secrets.KEY }} | |
port: ${{ secrets.PORT }} | |
source: nuxt.tar.gz | |
target: ${{ secrets.TARGET }} | |
- name: Deploy Applications # 部署应用 | |
if: ${{ contains(github.event.head_commit.message, 'build-and-deploy') }} | |
uses: appleboy/ssh-action@v1.1.0 | |
with: | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USERNAME }} | |
key: ${{ secrets.KEY }} | |
port: ${{ secrets.PORT }} | |
script: | | |
cd ${{ secrets.TARGET }} | |
tar -zxvf nuxt.tar.gz | |
rm -rf nuxt.tar.gz | |
pm2 delete grey-flowers | |
pm2 start ecosystem.config.js |