tool.xpcool.com/.gitea/workflows/deploy.yml
xpcool-bot 1ff576c704
All checks were successful
Build and Deploy (tool.xpcool.com) / build-and-deploy (push) Successful in 1m1s
ci: add PushPlus deployment notification
2026-08-24 22:45:05 +08:00

69 lines
2.8 KiB
YAML

# deployed by gitea act_runner (push to main/dev triggers this)
name: Build and Deploy (tool.xpcool.com)
on:
push:
branches: [main, dev]
workflow_dispatch:
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Install git (Tencent mirror apt)
run: |
sed -i 's|deb.debian.org|mirrors.cloud.tencent.com|g; s|security.debian.org|mirrors.cloud.tencent.com|g' /etc/apt/sources.list 2>/dev/null || true
sed -i 's|deb.debian.org|mirrors.cloud.tencent.com|g; s|security.debian.org|mirrors.cloud.tencent.com|g' /etc/apt/sources.list.d/debian.sources 2>/dev/null || true
apt-get update
apt-get install -y git
- name: Checkout (local Gitea, no external actions)
run: |
git clone --depth 1 --branch "${{ github.ref_name }}" https://oauth2:${{ github.token }}@git.xpcool.com/${{ github.repository }}.git .
git checkout ${{ github.sha }}
- name: Use npmmirror registry (faster in CN)
run: npm config set registry https://registry.npmmirror.com
- name: Enable pnpm via corepack
env:
COREPACK_NPM_REGISTRY: https://registry.npmmirror.com
run: |
corepack enable
corepack prepare pnpm@10 --activate
- name: Install dependencies
run: pnpm install
- name: Build (Vite)
run: pnpm build
- name: Deploy to /data/www/tool.xpcool.com
run: |
set -e
SRC=dist
DST=/data/www/tool.xpcool.com
if [ ! -d "$SRC" ]; then
echo "BUILD OUTPUT NOT FOUND: $SRC"
exit 1
fi
mkdir -p "$DST"
find "$DST" -mindepth 1 -delete
cp -r "$SRC"/. "$DST"/
chmod -R a+rX "$DST"
echo "Deployed tool.xpcool.com -> $DST"
- name: Notify success (PushPlus)
if: success()
run: |
curl -s -X POST "https://www.pushplus.plus/send" \
-H "Content-Type: application/json" \
-d '{"token":"5c20feb260304b218fcbe16694288684","title":"✅ 部署成功 tool.xpcool.com","content":"仓库: ${{ github.repository }}<br>分支: ${{ github.ref_name }}<br>提交: ${{ github.sha }}<br>触发人: ${{ github.actor }}<br>状态: 编译打包部署成功<br>访问: https://tool.xpcool.com","template":"html"}'
- name: Notify failure (PushPlus)
if: failure()
run: |
curl -s -X POST "https://www.pushplus.plus/send" \
-H "Content-Type: application/json" \
-d '{"token":"5c20feb260304b218fcbe16694288684","title":"❌ 部署失败 tool.xpcool.com","content":"仓库: ${{ github.repository }}<br>分支: ${{ github.ref_name }}<br>提交: ${{ github.sha }}<br>触发人: ${{ github.actor }}<br>状态: 构建或部署失败<br>日志: https://git.xpcool.com/${{ github.repository }}/actions","template":"html"}'