Skip to content

add github actions

add github actions #1

Workflow file for this run

name: Deploy Vue App
on:
push:
branches:
- main # 监听main分支的推送
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v3
with:
fetch-depth: 0 # 获取完整历史记录
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '23' # 根据项目需求设置Node.js版本
cache: 'npm'
- name: Install dependencies
run: npm install
- name: Build project
run: npm run build
- name: Checkout target branch
uses: actions/checkout@v3
with:
ref: web-build # 目标分支名称
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Copy build files
run: |
mkdir -p dist
cp -R ../dist/* ./dist/
- name: Commit and push build files
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add dist/
git commit -m "Deploy build files" || echo "No changes to commit"
git push origin web-build
- name: Clean up
run: |
git clean -fd