This commit is contained in:
shanshanzhong 2025-09-25 09:29:54 -07:00
parent 330a8c128b
commit 6524911c31

View File

@ -1,146 +1,84 @@
name: Publish Release Assets name: CI
run-name: Build and publish web assets and Docker images
on: on:
workflow_dispatch:
push: push:
branches: branches:
- main - cicd
paths:
- "apps/**"
- "packages/**"
- "package.json"
- "turbo.json"
- ".gitea/workflows/*.yml"
pull_request: pull_request:
types: [opened, synchronize, reopened] branches:
paths: - cicd
- "apps/**"
- "packages/**"
- "package.json"
- "turbo.json"
- ".gitea/workflows/*.yml"
release:
types: [published]
env: env:
# Gitea DOMAIN_URL: git.kxsw.us #*修改为你12
GIT_USERNAME: ${{ vars.GIT_USERNAME }} REPO: ${{ vars.REPO }}
GIT_PASSWORD: ${{ vars.GIT_PASSWORD }} TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
# Docker Hub TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} DOCKER_REGISTRY: registry.kxsw.us
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
# Host SSH (用于上传构建产物)
SSH_HOST: ${{ vars.SSH_HOST }}
SSH_PORT: ${{ vars.SSH_PORT }}
SSH_USER: ${{ vars.SSH_USER }}
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
jobs: jobs:
publish: build:
name: Publish Release Assets runs-on: ppanel-web02
runs-on: ubuntu-latest container:
image: node:20
strategy:
matrix:
# 只有node支持版本号别名
node: ['20.15.1']
steps: steps:
- name: Checkout codebase - name: Checkout code
uses: actions/checkout@v4 uses: https://gitea.cn/actions/checkout@v4
- name: Setup Bun - name: Install system tools (jq, docker, curl)
uses: oven-sh/setup-bun@v1 run: |
with: apt-get update
bun-version: 'latest' apt-get install -y jq curl ca-certificates docker.io
docker --version
jq --version
curl --version
- name: Cache Bun dependencies - name: Install Bun
uses: actions/cache@v3 run: |
with: curl -fsSL https://bun.sh/install | bash
path: | echo "BUN_INSTALL=/root/.bun" >> $GITHUB_ENV
~/.bun echo "PATH=/root/.bun/bin:${PATH}" >> $GITHUB_ENV
key: ${{ runner.os }}-bun-cache-${{ hashFiles('**/bun.lockb') }} /root/.bun/bin/bun --version
restore-keys: |
${{ runner.os }}-bun-cache-
- name: Install deps - name: Configure npm registry (npmmirror) and canvas mirror
run: bun install --cache run: |
echo "registry=https://registry.npmmirror.com" >> .npmrc
echo "canvas_binary_host_mirror=https://registry.npmmirror.com/-/binary/canvas" >> .npmrc
- name: Build - name: Install dependencies (bun)
run: bun install
- name: Run Build Project (turbo via bun)
run: bun run build run: bun run build
- name: Run publish script - name: Run Build Docker
run: | run: make build
chmod +x scripts/publish.sh
./scripts/publish.sh
- name: Upload tar.gz file to release - name: Push Docker Images
if: ${{ gitea.event_name == 'release' }} run: make push
uses: softprops/action-gh-release@v2
- name: Notify success to Telegram
uses: chapvic/telegram-notify@master
if: success()
with: with:
files: | token: ${{ env.TELEGRAM_BOT_TOKEN }}
out/ppanel-admin-web.tar.gz chat: ${{ env.TELEGRAM_CHAT_ID }}
out/ppanel-user-web.tar.gz status: ${{ job.status }}
token: ${{ secrets.GITEA_TOKEN }} title: ✅ 构建成功
message: ${{ github.repository }} 构建成功 · 分支: ${{ github.ref }} · 提1交: ${{ github.sha }}
footer: 触发者: ${{ github.actor }}
- name: Set up QEMU - name: Notify failure to Telegram
uses: docker/setup-qemu-action@v3 uses: chapvic/telegram-notify@master
if: failure()
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Install jq
run: sudo apt-get install -y jq
- name: Extract version from package.json
id: version
run: echo "PPANEL_VERSION=$(jq -r '.version' package.json)" >> $GITHUB_ENV
- name: Build and push Docker image for ppanel-admin-web
uses: docker/build-push-action@v6
with: with:
context: . token: ${{ env.TELEGRAM_BOT_TOKEN }}
file: ./docker/ppanel-admin-web/Dockerfile chat: ${{ env.TELEGRAM_CHAT_ID }}
platforms: linux/amd64,linux/arm64 status: ${{ job.status }}
push: true title: ❌ 构建失败
tags: | message: ${{ github.repository }} 构建失败 · 分支: ${{ github.ref }} · 提交: ${{ github.sha }}
${{ env.DOCKER_USERNAME }}/ppanel-admin-web:latest footer: 触发者: ${{ github.actor }}
${{ env.DOCKER_USERNAME }}/ppanel-admin-web:${{ env.PPANEL_VERSION }}
- name: Build and push Docker image for ppanel-user-web
uses: docker/build-push-action@v6
with:
context: .
file: ./docker/ppanel-user-web/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: |
${{ env.DOCKER_USERNAME }}/ppanel-user-web:latest
${{ env.DOCKER_USERNAME }}/ppanel-user-web:${{ env.PPANEL_VERSION }}
- name: Upload to SSH server (if configured)
if: ${{ env.SSH_HOST != '' }}
uses: appleboy/ssh-action@v1
with:
host: ${{ env.SSH_HOST }}
username: ${{ env.SSH_USER }}
key: ${{ env.SSH_PRIVATE_KEY }}
port: ${{ env.SSH_PORT }}
script: |
mkdir -p ~/releases/${{ gitea.ref_name || 'latest' }}
- name: Upload files via SCP (if SSH configured)
if: ${{ env.SSH_HOST != '' }}
uses: appleboy/scp-action@v1
with:
host: ${{ env.SSH_HOST }}
username: ${{ env.SSH_USER }}
key: ${{ env.SSH_PRIVATE_KEY }}
port: ${{ env.SSH_PORT }}
source: "out/*.tar.gz"
target: "~/releases/${{ gitea.ref_name || 'latest' }}/"
- name: Upload artifacts to Gitea
uses: actions/upload-artifact@v3
with:
name: ppanel-web-assets
path: |
out/ppanel-admin-web.tar.gz
out/ppanel-user-web.tar.gz