init push
This commit is contained in:
69
.github/workflows/backend.yml
vendored
Normal file
69
.github/workflows/backend.yml
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
name: Backend Build and Push
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "v[0-9]+.[0-9]+.[0-9]+*"
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
service: [api, consumer]
|
||||
timeout-minutes: 30
|
||||
|
||||
outputs:
|
||||
version: ${{ steps.get_version.outputs.VERSION }}
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
lfs: true
|
||||
submodules: true
|
||||
token: ${{ secrets.PRO_TOKEN }}
|
||||
|
||||
- name: Get version
|
||||
id: get_version
|
||||
run: |
|
||||
if [[ $GITHUB_REF == refs/tags/* ]]; then
|
||||
if [[ $GITHUB_REF == refs/tags/backend-* ]]; then
|
||||
echo "VERSION=${GITHUB_REF#refs/tags/backend-}" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
else
|
||||
echo "VERSION=${GITHUB_SHA::7}" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
with:
|
||||
platforms: 'arm64,amd64'
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Login to Aliyun Container Registry
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: chaitin-registry.cn-hangzhou.cr.aliyuncs.com
|
||||
username: ${{ secrets.CT_ALIYUN_USER }}
|
||||
password: ${{ secrets.CT_ALIYUN_PASS }}
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: ./backend
|
||||
file: ./backend/Dockerfile.${{ matrix.service }}.pro
|
||||
push: ${{ startsWith(github.ref, 'refs/tags/') }}
|
||||
platforms: linux/amd64, linux/arm64
|
||||
tags: chaitin-registry.cn-hangzhou.cr.aliyuncs.com/chaitin/panda-wiki-${{ matrix.service }}:${{ steps.get_version.outputs.VERSION }}
|
||||
build-args: |
|
||||
VERSION=${{ steps.get_version.outputs.VERSION }}
|
||||
cache-from: |
|
||||
type=gha,scope=${{ matrix.service }}
|
||||
cache-to: |
|
||||
type=gha,scope=${{ matrix.service }},mode=max
|
||||
102
.github/workflows/backend_check.yml
vendored
Normal file
102
.github/workflows/backend_check.yml
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
name: Backend Pull Request Check
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- 'backend/**'
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
golangci-lint:
|
||||
name: lint
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: '1.24'
|
||||
cache-dependency-path: 'backend/go.sum'
|
||||
- name: golangci-lint
|
||||
uses: golangci/golangci-lint-action@v8
|
||||
with:
|
||||
version: v2.1
|
||||
working-directory: backend
|
||||
args: --timeout 5m
|
||||
|
||||
go-mod-check:
|
||||
name: go mod check
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: '1.24'
|
||||
cache-dependency-path: 'backend/go.sum'
|
||||
|
||||
- name: Check go.mod formatting
|
||||
working-directory: backend
|
||||
run: |
|
||||
rm -rf cmd/api_pro
|
||||
if ! go mod tidy --diff ; then
|
||||
echo "::error::go.mod or go.sum is not properly formatted. Please run 'go mod tidy' locally and commit the changes."
|
||||
exit 1
|
||||
fi
|
||||
if ! go mod verify ; then
|
||||
echo "::error::go.mod or go.sum has unverified dependencies. Please run 'go mod verify' locally and commit the changes."
|
||||
exit 1
|
||||
fi
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
service: [api, consumer]
|
||||
timeout-minutes: 30
|
||||
|
||||
outputs:
|
||||
version: ${{ steps.get_version.outputs.VERSION }}
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
lfs: true
|
||||
|
||||
- name: Get version
|
||||
id: get_version
|
||||
run: |
|
||||
if [[ $GITHUB_REF == refs/tags/* ]]; then
|
||||
if [[ $GITHUB_REF == refs/tags/backend-* ]]; then
|
||||
echo "VERSION=${GITHUB_REF#refs/tags/backend-}" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
else
|
||||
echo "VERSION=${GITHUB_SHA::7}" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
with:
|
||||
platforms: 'arm64,amd64'
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Build
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: ./backend
|
||||
file: ./backend/Dockerfile.${{ matrix.service }}
|
||||
push: false
|
||||
platforms: linux/amd64, linux/arm64
|
||||
tags: chaitin-registry.cn-hangzhou.cr.aliyuncs.com/chaitin/panda-wiki-${{ matrix.service }}:${{ steps.get_version.outputs.VERSION }}
|
||||
build-args: |
|
||||
VERSION=${{ steps.get_version.outputs.VERSION }}
|
||||
cache-from: |
|
||||
type=gha,scope=${{ matrix.service }}
|
||||
cache-to: |
|
||||
type=gha,scope=${{ matrix.service }},mode=max
|
||||
163
.github/workflows/web.yml
vendored
Normal file
163
.github/workflows/web.yml
vendored
Normal file
@@ -0,0 +1,163 @@
|
||||
name: Web Build and Push
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- frontend-*
|
||||
- admin-*
|
||||
- app-*
|
||||
tags:
|
||||
- 'admin-v[0-9]+.[0-9]+.[0-9]+*'
|
||||
- 'app-v[0-9]+.[0-9]+.[0-9]+*'
|
||||
- 'v[0-9]+.[0-9]+.[0-9]+*'
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- 'web/**'
|
||||
|
||||
jobs:
|
||||
version:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
version: ${{ steps.get_version.outputs.VERSION }}
|
||||
|
||||
steps:
|
||||
- name: Get version
|
||||
id: get_version
|
||||
run: |
|
||||
if [[ $GITHUB_REF == refs/tags/* ]]; then
|
||||
# 支持 admin-v* / app-v* / v*
|
||||
if [[ $GITHUB_REF == refs/tags/admin-v* ]]; then
|
||||
echo "VERSION=${GITHUB_REF#refs/tags/admin-v}" >> $GITHUB_OUTPUT
|
||||
elif [[ $GITHUB_REF == refs/tags/app-v* ]]; then
|
||||
echo "VERSION=${GITHUB_REF#refs/tags/app-v}" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
else
|
||||
echo "VERSION=${GITHUB_SHA::7}" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [version]
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20'
|
||||
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v2
|
||||
with:
|
||||
version: 10
|
||||
|
||||
- name: Get pnpm store directory
|
||||
shell: bash
|
||||
run: |
|
||||
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
|
||||
|
||||
- name: Setup pnpm cache
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ${{ env.STORE_PATH }}
|
||||
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('web/pnpm-lock.yaml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-pnpm-store-
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
cd web
|
||||
pnpm install --frozen-lockfile --prefer-offline
|
||||
|
||||
- name: Setup Env for admin
|
||||
run: |
|
||||
cd web/admin
|
||||
echo "VITE_APP_VERSION=${{ needs.version.outputs.version }}" >> .env.production
|
||||
|
||||
- name: Build admin and app (parallel)
|
||||
env:
|
||||
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
|
||||
run: |
|
||||
cd web
|
||||
pnpm run build
|
||||
|
||||
- name: 'Tar admin files'
|
||||
run: tar -cvf web/admin/dist.tar web/admin/dist
|
||||
|
||||
- name: Upload admin build artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: admin-build
|
||||
path: web/admin/dist.tar
|
||||
if-no-files-found: error
|
||||
include-hidden-files: true
|
||||
|
||||
- name: 'Tar app files'
|
||||
run: tar -cvf web/app/dist.tar web/app/dist
|
||||
|
||||
- name: Upload app build artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: app-build
|
||||
path: web/app/dist.tar
|
||||
if-no-files-found: error
|
||||
include-hidden-files: true
|
||||
|
||||
package:
|
||||
needs: [build, version]
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
project: [admin, app]
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Download build artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: ${{ matrix.project }}-build
|
||||
|
||||
- name: Extract files
|
||||
run: |
|
||||
tar -xvf dist.tar
|
||||
|
||||
- name: Check file structure
|
||||
run: |
|
||||
echo "Current directory: $(pwd)"
|
||||
echo "Listing web/${{ matrix.project }} directory:"
|
||||
ls -la web/${{ matrix.project }}
|
||||
echo "Listing web/${{ matrix.project }}/dist directory:"
|
||||
ls -la web/${{ matrix.project }}/dist
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Login to Aliyun Container Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: chaitin-registry.cn-hangzhou.cr.aliyuncs.com
|
||||
username: ${{ secrets.CT_ALIYUN_USER }}
|
||||
password: ${{ secrets.CT_ALIYUN_PASS }}
|
||||
|
||||
- name: Package and push
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: ./web/${{ matrix.project }}
|
||||
file: ./web/${{ matrix.project }}/Dockerfile
|
||||
push: true
|
||||
platforms: linux/amd64, linux/arm64
|
||||
tags: chaitin-registry.cn-hangzhou.cr.aliyuncs.com/chaitin/panda-wiki-${{ matrix.project == 'admin' && 'nginx' || 'app' }}:v${{ needs.version.outputs.version }}
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
Reference in New Issue
Block a user