68 lines
2.2 KiB
YAML
68 lines
2.2 KiB
YAML
name: study-online
|
|
run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
- "release**"
|
|
|
|
env:
|
|
BUILD: staging
|
|
|
|
jobs:
|
|
Explore-Gitea-Actions:
|
|
runs-on: stream9
|
|
steps:
|
|
- run: echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event."
|
|
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by Gitea!"
|
|
- run: echo "🔎 The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}."
|
|
- run: echo "Gitea job id ${{ gitea.run_id }}."
|
|
- name: Check out repository code
|
|
uses: https://gitea.yantootech.com/neil/checkout@v4
|
|
with:
|
|
fetch-depth: 1
|
|
- run: echo "💡 The ${{ gitea.repository }} repository has been cloned to the runner."
|
|
- run: echo "🖥️ The workflow is now ready to test your code on the runner."
|
|
|
|
# 设置环境和 Node.js
|
|
- name: Setup environment
|
|
run: |
|
|
export NVM_DIR="$HOME/.nvm"
|
|
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
|
|
unset CI
|
|
nvm use 23.5.0
|
|
|
|
# 安装依赖
|
|
- name: Install dependencies
|
|
run: |
|
|
echo "Installing dependencies..."
|
|
# 使用 --legacy-peer-deps 避免依赖冲突
|
|
npm install --legacy-peer-deps
|
|
|
|
# 构建项目
|
|
- name: Build project
|
|
run: |
|
|
echo "Building project..."
|
|
# 设置环境变量
|
|
export NODE_OPTIONS="--no-warnings"
|
|
export VITE_CJS_IGNORE_WARNING=true
|
|
|
|
# 执行构建
|
|
npm run build
|
|
|
|
# 移动构建产物
|
|
- name: Move dist folder to target directory
|
|
run: |
|
|
if [ ! -d "dist" ]; then
|
|
echo "Error: dist directory not found"
|
|
ls -la
|
|
exit 1
|
|
fi
|
|
echo "Dist directory found, moving to /yantoo/frontend/study-online/"
|
|
|
|
sudo mkdir -p /yantoo/frontend/study-online
|
|
sudo rm -rf /yantoo/frontend/study-online/*
|
|
sudo cp -r dist/* /yantoo/frontend/study-online/
|
|
|
|
echo "Files successfully moved to /yantoo/frontend/study-online/"
|