ci: 为项目添加CI/CD功能 #30

Manually merged
remilia merged 18 commits from ci/gitea-actions into master 2025-09-26 17:14:03 +08:00
Showing only changes of commit ad66ae1b46 - Show all commits

View File

@ -3,7 +3,7 @@ name: deploy to server
on: push on: push
jobs: jobs:
build: build-and-deploy:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
@ -24,6 +24,8 @@ jobs:
key: ${{ runner.os }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }} key: ${{ runner.os }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: | restore-keys: |
${{ runner.os }}-pnpm- ${{ runner.os }}-pnpm-
- name: Install dependencies
run: pnpm install
# Nuxt 构建缓存,加快二次构建 # Nuxt 构建缓存,加快二次构建
- name: Cache Nuxt build - name: Cache Nuxt build
uses: actions/cache@v4 uses: actions/cache@v4
@ -32,28 +34,7 @@ jobs:
key: ${{ runner.os }}-nuxt-${{ hashFiles('pnpm-lock.yaml') }} key: ${{ runner.os }}-nuxt-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: | restore-keys: |
${{ runner.os }}-nuxt- ${{ runner.os }}-nuxt-
- name: Install dependencies
run: pnpm install
- name: Build project - name: Build project
run: pnpm run build run: pnpm run build
- name: Upload build output
uses: actions/upload-artifact@v4
with:
name: nuxt-output
path: .output/
deploy:
runs-on: ubuntu-latest
needs: build
# if: github.ref == 'refs/heads/master'
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Download build output
uses: actions/download-artifact@v4
with:
name: nuxt-output
path: .output/
- name: Rsync build artifact to server - name: Rsync build artifact to server
run: rsync -avz --delete .output/ remilia@192.168.86.5:/home/remilia/Jinshenwebsite/front-build run: rsync -avz --delete .output/ remilia@192.168.86.5:/home/remilia/Jinshenwebsite/front-build