Files
xgj/release-web/examples/full-cicd.yml

84 lines
2.0 KiB
YAML

name: "完整CI/CD流程"
on:
push:
branches:
- main
- develop
pull_request:
branches:
- main
env:
REGISTRY: docker-registry.bjxgj.com
NODE_VERSION: "18"
jobs:
test:
runs-on: ubuntu-latest
name: "代码测试"
steps:
- name: 检出代码
uses: actions/checkout@v4
- name: 设置Node.js环境
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: 安装依赖
uses: actions/xgj/npm-install@main
with:
package-manager: "npm"
- name: 代码检查
run: |
npm run lint
npm run type-check
- name: 运行测试
run: npm run test:ci
- name: 构建项目
run: npm run build
release:
runs-on: ubuntu-latest
name: "发布构建"
needs: test
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop')
steps:
- name: 检出代码
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITEA_TOKEN }}
- name: 设置构建环境
uses: actions/xgj/setup-env@main
with:
docker-registry: ${{ env.REGISTRY }}
docker-password: ${{ secrets.DOCKER_PASSWORD }}
kube-config: ${{ secrets.KUBE_CONFIG }}
- name: 安装依赖
uses: actions/xgj/npm-install@main
with:
package-manager: "npm"
cache-prefix: "release"
- name: 发布构建
id: release
uses: actions/xgj/release-web@main
env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
APP_ENV: ${{ github.ref == 'refs/heads/main' && 'production' || 'develop' }}
- name: 通知发布结果
run: |
echo "🎉 发布完成!"
echo "📦 版本: ${{ steps.release.outputs.version }}"
echo "🌍 环境: ${{ github.ref == 'refs/heads/main' && '生产环境' || '开发环境' }}"