Skip to content

Commit

Permalink
add github action to compile
Browse files Browse the repository at this point in the history
  • Loading branch information
snowtafir committed Aug 4, 2024
1 parent 5936eaf commit cc3545c
Showing 1 changed file with 91 additions and 0 deletions.
91 changes: 91 additions & 0 deletions .github/workflows/build-deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: 构建和部署

on:
push:
branches:
- dev3

permissions:
contents: write

jobs:
build-and-deploy:
runs-on: ubuntu-latest

steps:
- name: 🚀 检出代码
uses: actions/checkout@v4

- name: 🏗️ 安装 Node.js
uses: actions/setup-node@v4
with:
node-version: 18

- name: 📦 安装 yarn
run: npm install -g yarn

- name: 📦 列出node版本
run: |
pwd
node -v
- name: 📦 列出npm版本
run: npm -v

- name: 📦 列出yarn版本
run: yarn -v

- name: 🔧 安装依赖
run: yarn install

- name: 🛠️ 构建项目
run: yarn build

- name: 📂 创建临时目录
run: mkdir ./../temp_dist/

- name: 📄 列出当前目录文件
run: ls -l

- name: 🚚 移动构建文件到临时目录
run: mv ./dist/* ../temp_dist/

- name: 🛠️ 配置Git用户信息
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
- name: 🔄 获取最新代码
run: git fetch

- name: 🔀 切换到main3分支
run: git checkout main3

- name: 🔄 拉取main3分支最新代码
run: git pull origin main3

- name: 📄 列出main3分支文件
run: ls -l

- name: 🧹 清理当前目录(保留.git)
run: find . -mindepth 1 -maxdepth 1 ! -name '.git' -exec rm -rf {} +

- name: 🚚 从临时目录移动文件到当前目录
run: mv ./../temp_dist/* ./

- name: 🗑️ 删除临时目录
run: rm -rf ./../temp_dist

- name: 📄 列出当前目录文件
run: ls -l

- name: 📥 添加所有更改到Git
run: git add .

- name: 💬 提交更改
run: git commit -m "${{ github.event.head_commit.message }}"

- name: 🚀 推送到main3分支
run: git push origin main3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit cc3545c

Please sign in to comment.