合并 internal → main: 退款/提现/激活/CI 全面优化 #4

Open
shanshanzhong147 wants to merge 76 commits from internal into main
3 changed files with 40 additions and 37 deletions
Showing only changes of commit f6f2ca9a29 - Show all commits
+15 -15
View File
@@ -1,4 +1,4 @@
name: CI
name: 持续集成
on:
pull_request:
@@ -16,30 +16,30 @@ concurrency:
jobs:
build-and-test:
name: Build, vet, test
name: 构建/Vet/测试
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout
uses: actions/checkout@v4
- name: 检出代码
uses: actions/checkout@v6
- name: Setup Go
uses: actions/setup-go@v5
- name: 配置 Go 环境
uses: actions/setup-go@v6
with:
go-version-file: go.mod
cache: true
- name: Download modules
- name: 下载依赖模块
run: go mod download
- name: Build
- name: 构建
run: go build ./...
- name: Vet
- name: 运行 go vet
run: go vet ./...
- name: Test
- name: 运行测试
run: go test -race -count=1 ./...
lint:
@@ -48,20 +48,20 @@ jobs:
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v4
- name: 检出代码
uses: actions/checkout@v6
with:
# Fetch base ref so golangci-lint can diff against it for only-new-issues.
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v5
- name: 配置 Go 环境
uses: actions/setup-go@v6
with:
go-version-file: go.mod
cache: true
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
uses: golangci/golangci-lint-action@v9
with:
version: latest
args: --timeout=5m
+21 -18
View File
@@ -1,4 +1,4 @@
name: Deploy Staging
name: 测试环境部署
on:
push:
@@ -20,20 +20,23 @@ env:
STAGING_HOST: ${{ vars.STAGING_HOST || '154.12.35.103' }}
STAGING_DEPLOY_PATH: ${{ vars.STAGING_DEPLOY_PATH || '/opt/hifast-server' }}
STAGING_HEALTHCHECK_URL: ${{ vars.STAGING_HEALTHCHECK_URL || 'http://127.0.0.1:8080/v1/common/heartbeat' }}
# 关闭 docker/build-push-action 自动生成的英文 job summary
# 我们用 Telegram 通知传递部署结果,不需要 GitHub Actions 页面上那段英文
DOCKER_BUILD_SUMMARY: false
jobs:
build-and-deploy:
name: Build image and deploy to staging
name: 构建镜像并部署到测试环境
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v4
- name: 检出代码
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Collect release notes
- name: 收集发布说明
id: release-notes
run: |
set -euo pipefail
@@ -55,20 +58,20 @@ jobs:
echo "EOF"
} >> "$GITHUB_OUTPUT"
- name: Setup Go
uses: actions/setup-go@v5
- name: 配置 Go 环境
uses: actions/setup-go@v6
with:
go-version-file: go.mod
cache: true
- name: Test
- name: 运行测试
run: go test ./...
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: 配置 Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Build and push image
uses: docker/build-push-action@v6
- name: 构建并推送镜像
uses: docker/build-push-action@v7
with:
context: .
file: ./Dockerfile
@@ -81,8 +84,8 @@ jobs:
${{ env.IMAGE_NAME }}:${{ github.sha }}
${{ env.IMAGE_NAME }}:staging
- name: Copy compose file
uses: appleboy/scp-action@v0.1.7
- name: 上传 compose 配置
uses: appleboy/scp-action@v1.0.0
with:
host: ${{ env.STAGING_HOST }}
username: ${{ secrets.STAGING_SSH_USER }}
@@ -91,8 +94,8 @@ jobs:
source: docker-compose.cloud.yml
target: /tmp/hifast-server-deploy/
- name: Deploy on staging server
uses: appleboy/ssh-action@v1.0.3
- name: 在测试服务器上部署
uses: appleboy/ssh-action@v1.2.5
with:
host: ${{ env.STAGING_HOST }}
username: ${{ secrets.STAGING_SSH_USER }}
@@ -193,7 +196,7 @@ jobs:
docker_cmd image prune -f || true
exit 1
- name: Notify Telegram on success
- name: Telegram 成功通知
if: success()
env:
TG_BOT_TOKEN: ${{ secrets.TG_BOT_TOKEN }}
@@ -221,7 +224,7 @@ jobs:
--data-urlencode "chat_id=${TG_CHAT_ID}" \
--data-urlencode "text=${MESSAGE}" || echo "Telegram 通知发送失败,但发布结果不受影响。"
- name: Notify Telegram on failure
- name: Telegram 失败通知
if: failure()
env:
TG_BOT_TOKEN: ${{ secrets.TG_BOT_TOKEN }}
+4 -4
View File
@@ -9,7 +9,7 @@
```
Multica issue → 分支 fix/<num>-中文简述 → 推 github → 开 PR → CI 绿 → 架构师 approve
→ GitHub UI Squash and merge 进 internal → Deploy Staging 自动跑
→ GitHub UI Squash and merge 进 internal → 测试环境部署 (deploy-staging.yml) 自动跑
→ QA 在 staging 验收 → Multica issue → done
发版时:架构师把 internal squash 进 main → 对外正式版本
@@ -111,7 +111,7 @@ gh pr create --base internal --title '修复(#<num>): ...' --body-file <path>
- **必须用 GitHub UI 的 "Squash and merge"**。
- squash 后 commit message 由架构师编辑确认:保持 `<类型>(#<num>): ...` 形式 + 必要正文。
- 合并按钮按下后 PR 自动 close,分支由 GitHub 自动删("Automatically delete head branches" 应开启)。
- 架构师在 Multica issue 上 `@运维工程师` 附 commit hash,通知可以部署(虽然 Deploy Staging 已自动跑,但运维需要确认部署状态)。
- 架构师在 Multica issue 上 `@运维工程师` 附 commit hash,通知可以部署(虽然测试环境部署 workflow 已自动跑,但运维需要确认部署状态)。
**禁止做的事**
- ❌ 在本地 squash 再 `git push``internal` / `main`
@@ -121,7 +121,7 @@ gh pr create --base internal --title '修复(#<num>): ...' --body-file <path>
- ❌ 自己 approve 自己的 PR
- ❌ 未经测试工程师验收的分支合并(架构师红线)
### 2.7 Deploy Staging 自动触发
### 2.7 测试环境部署自动触发 (`.github/workflows/deploy-staging.yml`)
合并到 `internal` 后,`.github/workflows/deploy-staging.yml` 自动触发:
@@ -159,7 +159,7 @@ gh pr create --base main --head internal --title '发版: <版本号>'
| `todo` | 已排期,待 assigned agent 开始 |
| `in_progress` | 分支已开始写,未 push |
| `in_review` | PR 已开,等 review / CI / merge |
| `done` | PR merged + Deploy Staging 通过 + QA 验收通过 |
| `done` | PR merged + 测试环境部署通过 + QA 验收通过 |
**三个条件没全满足就不要标 done**——否则验收链路看不到真问题。