docker-build.yml 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. # 自动构建并推送 GHCR:push master 触发
  2. # 镜像 tag:latest + 日期时间 - 提交哈希(如 20260815T0054-a1b2c3d)
  3. #
  4. # Auto-build and push to GHCR: triggered on push to master
  5. # Image tags: latest + datetime-commit-hash (e.g. 20260815T0054-a1b2c3d)
  6. name: build-push-ghcr
  7. on:
  8. push:
  9. branches: [master]
  10. env:
  11. IMAGE: ghcr.io/xidong-ai/deepseek-harness-web-docker
  12. jobs:
  13. # 推送前冒烟:构建镜像并跑端到端检查(basic auth / 特权 API fence / 双进程 / trustedHosts 注入),失败则不推送
  14. # 手动 push 的代码不再未经验证直接发布
  15. #
  16. # Pre-push smoke test: build the image and run end-to-end checks (basic auth / privileged-API fence /
  17. # both processes / trustedHosts injection); a failure blocks the push, so manually pushed code
  18. # is no longer published unverified
  19. verify:
  20. runs-on: ubuntu-latest
  21. permissions:
  22. contents: read
  23. steps:
  24. - uses: actions/checkout@v4
  25. - name: 提取 DSH_VERSION
  26. id: version
  27. run: |
  28. echo "version=$(grep -E '^ARG DSH_VERSION=' Dockerfile | head -n1 | cut -d= -f2)" >> "$GITHUB_OUTPUT"
  29. - name: 构建并冒烟测试
  30. run: |
  31. scripts/smoke-test.sh "${{ steps.version.outputs.version }}"
  32. build:
  33. needs: verify
  34. runs-on: ubuntu-latest
  35. permissions:
  36. contents: read
  37. packages: write
  38. steps:
  39. - uses: actions/checkout@v4
  40. - name: Set up QEMU
  41. uses: docker/setup-qemu-action@v3
  42. - name: Set up Docker Buildx
  43. uses: docker/setup-buildx-action@v3
  44. - name: Log in to GHCR
  45. uses: docker/login-action@v3
  46. with:
  47. registry: ghcr.io
  48. username: ${{ github.actor }}
  49. password: ${{ secrets.GITHUB_TOKEN }}
  50. - name: 生成日期时间 - 哈希 tag
  51. id: meta
  52. run: |
  53. echo "tag=$(date +%Y%m%dT%H%M)-${GITHUB_SHA::7}" >> "$GITHUB_OUTPUT"
  54. - name: Build and push
  55. uses: docker/build-push-action@v6
  56. with:
  57. context: .
  58. push: true
  59. platforms: linux/amd64,linux/arm64
  60. tags: |
  61. ${{ env.IMAGE }}:latest
  62. ${{ env.IMAGE }}:${{ steps.meta.outputs.tag }}