i9
This commit is contained in:
parent
71dbb921ff
commit
d37e2abf0d
@ -14,6 +14,12 @@ env:
|
||||
TELEGRAM_BOT_TOKEN: 8114337882:AAHkEx03HSu7RxN4IHBJJEnsK9aPPzNLIk0
|
||||
TELEGRAM_CHAT_ID: "-4940243803"
|
||||
DOCKER_REGISTRY: registry.kxsw.us
|
||||
DOCKER_BUILDKIT: 1
|
||||
# Host SSH
|
||||
SSH_HOST: ${{ vars.SSH_HOST }}
|
||||
SSH_PORT: ${{ vars.SSH_PORT }}
|
||||
SSH_USER: ${{ vars.SSH_USER }}
|
||||
SSH_PASSWORD: ${{ vars.SSH_PASSWORD }}
|
||||
|
||||
jobs:
|
||||
build:
|
||||
@ -75,6 +81,34 @@ jobs:
|
||||
echo "registry=https://registry.npmmirror.com" >> .npmrc
|
||||
echo "canvas_binary_host_mirror=https://registry.npmmirror.com/-/binary/canvas" >> .npmrc
|
||||
|
||||
- name: Install dependencies cache (Bun)
|
||||
uses: https://gitea.cn/actions/cache@v3
|
||||
with:
|
||||
path: /root/.bun
|
||||
key: bun-${{ runner.os }}-${{ matrix.node }}-${{ hashFiles('bun.lock') }}
|
||||
restore-keys: |
|
||||
bun-${{ runner.os }}-${{ matrix.node }}-
|
||||
|
||||
- name: Install dependencies cache (node_modules)
|
||||
uses: https://gitea.cn/actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
node_modules
|
||||
apps/admin/node_modules
|
||||
apps/user/node_modules
|
||||
packages/ui/node_modules
|
||||
key: nm-${{ runner.os }}-${{ matrix.node }}-${{ hashFiles('bun.lock') }}
|
||||
restore-keys: |
|
||||
nm-${{ runner.os }}-${{ matrix.node }}-
|
||||
|
||||
- name: Turborepo cache (.turbo)
|
||||
uses: https://gitea.cn/actions/cache@v3
|
||||
with:
|
||||
path: .turbo
|
||||
key: turbo-${{ runner.os }}-${{ hashFiles('turbo.json') }}-${{ hashFiles('bun.lock') }}
|
||||
restore-keys: |
|
||||
turbo-${{ runner.os }}-
|
||||
|
||||
- name: Install dependencies (bun)
|
||||
run: bun install
|
||||
|
||||
@ -111,6 +145,16 @@ jobs:
|
||||
- name: Read version from package.json
|
||||
run: echo "VERSION=$(jq -r .version package.json)" >> $GITHUB_ENV
|
||||
|
||||
- name: Cache Next.js build artifacts (.next/cache)
|
||||
uses: https://gitea.cn/actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
apps/admin/.next/cache
|
||||
apps/user/.next/cache
|
||||
key: nextcache-${{ runner.os }}-${{ hashFiles('apps/**') }}-${{ hashFiles('packages/**') }}-${{ hashFiles('turbo.json') }}-${{ hashFiles('bun.lock') }}
|
||||
restore-keys: |
|
||||
nextcache-${{ runner.os }}-
|
||||
|
||||
- name: Build Admin (turbo via bun)
|
||||
if: env.BUILD_TARGET == 'admin' || env.BUILD_TARGET == 'both'
|
||||
run: bun run build --filter=ppanel-admin-web
|
||||
@ -135,13 +179,39 @@ jobs:
|
||||
if: env.BUILD_TARGET == 'user' || env.BUILD_TARGET == 'both'
|
||||
run: docker push ${{ env.DOCKER_REGISTRY }}/ppanel/ppanel-user-web:${{ env.VERSION }}
|
||||
|
||||
- name: Run Admin container after push
|
||||
- name: Deploy Admin via SSH (docker run)
|
||||
if: env.BUILD_TARGET == 'admin' || env.BUILD_TARGET == 'both'
|
||||
run: make admin-run
|
||||
uses: appleboy/ssh-action@v0.1.11
|
||||
with:
|
||||
host: ${{ env.SSH_HOST }}
|
||||
port: ${{ env.SSH_PORT }}
|
||||
username: ${{ env.SSH_USER }}
|
||||
password: ${{ env.SSH_PASSWORD }}
|
||||
script: |
|
||||
set -e
|
||||
REG="${{ env.DOCKER_REGISTRY }}"
|
||||
VERSION="${{ env.VERSION }}"
|
||||
echo "Deploying admin: $REG/ppanel/ppanel-admin-web:$VERSION"
|
||||
docker pull "$REG/ppanel/ppanel-admin-web:$VERSION" || true
|
||||
docker rm -f ppanel-admin-web || true
|
||||
docker run -d --name ppanel-admin-web --restart=always -p 3000:3000 -e NEXT_PUBLIC_API_URL="https://api.airoport.co" "$REG/ppanel/ppanel-admin-web:$VERSION"
|
||||
|
||||
- name: Run User container after push
|
||||
- name: Deploy User via SSH (docker run)
|
||||
if: env.BUILD_TARGET == 'user' || env.BUILD_TARGET == 'both'
|
||||
run: make user-run
|
||||
uses: appleboy/ssh-action@v0.1.11
|
||||
with:
|
||||
host: ${{ env.SSH_HOST }}
|
||||
port: ${{ env.SSH_PORT }}
|
||||
username: ${{ env.SSH_USER }}
|
||||
password: ${{ env.SSH_PASSWORD }}
|
||||
script: |
|
||||
set -e
|
||||
REG="${{ env.DOCKER_REGISTRY }}"
|
||||
VERSION="${{ env.VERSION }}"
|
||||
echo "Deploying user: $REG/ppanel/ppanel-user-web:$VERSION"
|
||||
docker pull "$REG/ppanel/ppanel-user-web:$VERSION" || true
|
||||
docker rm -f ppanel-user-web || true
|
||||
docker run -d --name ppanel-user-web --restart=always -p 3001:3000 -e NEXT_PUBLIC_API_URL="https://api.airoport.co" "$REG/ppanel/ppanel-user-web:$VERSION"
|
||||
|
||||
- name: Notify success to Telegram
|
||||
uses: chapvic/telegram-notify@master
|
||||
@ -151,7 +221,7 @@ jobs:
|
||||
chat: ${{ env.TELEGRAM_CHAT_ID }}
|
||||
status: ${{ job.status }}
|
||||
title: ✅ 构建成功
|
||||
message: "${{ gitea.repository }} 构建成功 · 分支: ${{ gitea.ref }} · 提交: ${{ gitea.sha }} · 目标: ${{ env.BUILD_TARGET }} · 版本: ${{ env.VERSION }}"
|
||||
message: "${{ gitea.repository }} 构建成功"
|
||||
footer: "触发者: ${{ gitea.actor }}"
|
||||
parse_mode: HTML
|
||||
|
||||
@ -163,6 +233,6 @@ jobs:
|
||||
chat: ${{ env.TELEGRAM_CHAT_ID }}
|
||||
status: ${{ job.status }}
|
||||
title: ❌ 构建失败
|
||||
message: "${{ gitea.repository }} 构建失败 · 分支: ${{ gitea.ref }} · 提交: ${{ gitea.sha }} · 目标: ${{ env.BUILD_TARGET }} · 版本: ${{ env.VERSION }}"
|
||||
message: "${{ gitea.repository }} 构建失败
|
||||
footer: "触发者: ${{ gitea.actor }}"
|
||||
parse_mode: HTML
|
||||
|
||||
11
Makefile
11
Makefile
@ -71,17 +71,6 @@ ensure-version:
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
.PHONY: admin-run
|
||||
admin-run: ensure-version ## Run the admin container locally (binds to localhost:3000)
|
||||
@echo "Running admin container from image ${ADMIN_IMAGE}:${VERSION} on http://localhost:3000 ..."
|
||||
docker run --name ppanel-admin-web --rm -e NEXT_PUBLIC_API_URL=https://airoport.co -p 3000:3000 ${ADMIN_IMAGE}:${VERSION}
|
||||
|
||||
.PHONY: user-run
|
||||
user-run: ensure-version ## Run the user container locally (binds to localhost:3001)
|
||||
@echo "Running user container from image ${USER_IMAGE}:${VERSION} on http://localhost:3001 ..."
|
||||
docker run --name ppanel-user-web --rm -p 3001:3000 ${USER_IMAGE}:${VERSION}
|
||||
|
||||
|
||||
# ==============================================================================
|
||||
# Other Targets
|
||||
# ==============================================================================
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user