diff --git a/.github/workflows/check-fork.yml b/.github/workflows/check-fork.yml new file mode 100644 index 000000000..d51e507d0 --- /dev/null +++ b/.github/workflows/check-fork.yml @@ -0,0 +1,19 @@ +name: Check Fork Status +on: + # schedule: + # - cron: '30 0,5,12 * * *' + workflow_dispatch: +jobs: + check-fork: + runs-on: ubuntu-latest + steps: + - name: Check fork status + run: | + BEHIND=$(gh api repos/RightNow-AI/openfang/compare/RightNow-AI:main...birdxs:main --jq '.behind_by') + if [ "$BEHIND" -gt 0 ]; then + COMMITS=$(gh api repos/RightNow-AI/openfang/compare/RightNow-AI:main...birdxs:main --jq '.commits[:5] | .[] | "[\(.sha[:7])] \(.commit.message | split("\n")[0])"') + curl -X POST "${{ secrets.FEISHU_WEBHOOK }}" -H "Content-Type: application/json" -d "{\"msg_type\": \"text\", \"content\": {\"text\": \"📦 birdxs/openfang\n⚠️ 落后上游 $BEHIND 个 commits\n\n📝 新增提交:\n$COMMITS\"}}" + fi + env: + GH_TOKEN: ${{ secrets.GH_TOKEN }} + FEISHU_WEBHOOK: ${{ secrets.FEISHU_WEBHOOK }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 84b2b3528..c186b68c4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,10 +1,10 @@ name: CI on: - push: - branches: [main] - pull_request: - branches: [main] + #push: + #branches: [main] + #pull_request: + # branches: [main] env: CARGO_TERM_COLOR: always diff --git a/.github/workflows/ghcr-dockerhub-amd64.yml b/.github/workflows/ghcr-dockerhub-amd64.yml new file mode 100644 index 000000000..d784a9646 --- /dev/null +++ b/.github/workflows/ghcr-dockerhub-amd64.yml @@ -0,0 +1,119 @@ +name: Build AMD64 Docker Images 2026.2.28同时推送镜像至ghcr和dockerhub + +on: + workflow_dispatch: + inputs: + image_tag: + description: 'Image tag version (e.g., v1.0.0, latest)' + required: true + default: 'latest' + +env: + GHCR_REGISTRY: ghcr.io + DOCKERHUB_REGISTRY: docker.io + # GitHub 仓库全名作为 GHCR 镜像名 + GHCR_IMAGE_NAME: ${{ github.repository }} + # Docker Hub 镜像名(需要根据实际情况设置) + DOCKERHUB_IMAGE_NAME: ${{ secrets.DOCKERHUB_USERNAME }}/${{ github.event.repository.name }} + +jobs: + build-and-push: + runs-on: ubuntu-24.04 + permissions: + contents: read + packages: write + id-token: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + driver-opts: | + image=moby/buildkit:master + network=host + + - name: Set up QEMU for multi-platform build + uses: docker/setup-qemu-action@v3 + + # 登录到 GHCR + - name: Log in to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ${{ env.GHCR_REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + # 登录到 Docker Hub(需要预先设置 secrets.DOCKERHUB_USERNAME 和 secrets.DOCKERHUB_TOKEN) + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + registry: ${{ env.DOCKERHUB_REGISTRY }} + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + # 为 GHCR 生成元数据 + - name: Extract metadata for GHCR + id: meta-ghcr + uses: docker/metadata-action@v5 + with: + images: ${{ env.GHCR_REGISTRY }}/${{ env.GHCR_IMAGE_NAME }} + tags: | + type=raw,value=${{ inputs.image_tag }} + type=raw,value=latest,enable=${{ inputs.image_tag != 'latest' }} + flavor: | + latest=true + + # 为 Docker Hub 生成元数据 + - name: Extract metadata for Docker Hub + id: meta-dockerhub + uses: docker/metadata-action@v5 + with: + images: ${{ env.DOCKERHUB_REGISTRY }}/${{ env.DOCKERHUB_IMAGE_NAME }} + tags: | + type=raw,value=${{ inputs.image_tag }} + type=raw,value=latest,enable=${{ inputs.image_tag != 'latest' }} + flavor: | + latest=true + + # 构建并推送多架构镜像到两个注册表 + - name: Build and push multi-arch images + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile + platforms: linux/amd64 + push: true + tags: | + ${{ steps.meta-ghcr.outputs.tags }} + ${{ steps.meta-dockerhub.outputs.tags }} + labels: ${{ steps.meta-ghcr.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Generate summary + run: | + echo "### Docker Images Built and Pushed Successfully 🎉" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "**GitHub Container Registry (GHCR):**" >> $GITHUB_STEP_SUMMARY + echo "- Image: \`${{ env.GHCR_REGISTRY }}/${{ env.GHCR_IMAGE_NAME }}\`" >> $GITHUB_STEP_SUMMARY + echo "- Tags: ${{ inputs.image_tag }}${{ inputs.image_tag != 'latest' && ', latest' || '' }}" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "**Docker Hub:**" >> $GITHUB_STEP_SUMMARY + echo "- Image: \`${{ env.DOCKERHUB_REGISTRY }}/${{ env.DOCKERHUB_IMAGE_NAME }}\`" >> $GITHUB_STEP_SUMMARY + echo "- Tags: ${{ inputs.image_tag }}${{ inputs.image_tag != 'latest' && ', latest' || '' }}" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "**Platforms:** linux/amd64, linux/arm64" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "### Pull Commands:" >> $GITHUB_STEP_SUMMARY + echo "**GHCR:**" >> $GITHUB_STEP_SUMMARY + echo '```bash' >> $GITHUB_STEP_SUMMARY + echo "docker pull ${{ env.GHCR_REGISTRY }}/${{ env.GHCR_IMAGE_NAME }}:${{ inputs.image_tag }}" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "**Docker Hub:**" >> $GITHUB_STEP_SUMMARY + echo '```bash' >> $GITHUB_STEP_SUMMARY + echo "docker pull ${{ env.DOCKERHUB_REGISTRY }}/${{ env.DOCKERHUB_IMAGE_NAME }}:${{ inputs.image_tag }}" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/ghcr-dockerhub-new.yml b/.github/workflows/ghcr-dockerhub-new.yml new file mode 100644 index 000000000..bf2c5059d --- /dev/null +++ b/.github/workflows/ghcr-dockerhub-new.yml @@ -0,0 +1,145 @@ +name: kimi优化加速编译Build and Push Multi-Arch Docker Images (Optimized) + +on: + workflow_dispatch: + inputs: + image_tag: + description: 'Image tag version (e.g., v1.0.0, latest)' + required: true + default: 'latest' + +env: + GHCR_REGISTRY: ghcr.io + DOCKERHUB_REGISTRY: docker.io + GHCR_IMAGE_NAME: ${{ github.repository }} + DOCKERHUB_IMAGE_NAME: ${{ secrets.DOCKERHUB_USERNAME }}/${{ github.event.repository.name }} + +jobs: + # AMD64 构建 - 使用 GitHub 标准 x86 runner + build-amd64: + runs-on: ubuntu-24.04 + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to GHCR + uses: docker/login-action@v3 + with: + registry: ${{ env.GHCR_REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + registry: ${{ env.DOCKERHUB_REGISTRY }} + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push AMD64 + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile + platforms: linux/amd64 + push: true + tags: | + ${{ env.GHCR_REGISTRY }}/${{ env.GHCR_IMAGE_NAME }}:${{ inputs.image_tag }}-amd64 + ${{ env.DOCKERHUB_REGISTRY }}/${{ env.DOCKERHUB_IMAGE_NAME }}:${{ inputs.image_tag }}-amd64 + # 关键:分离的缓存作用域,避免与 ARM 冲突 + cache-from: type=gha,scope=amd64-${{ github.ref_name }} + cache-to: type=gha,mode=max,scope=amd64-${{ github.ref_name }} + + # ARM64 构建 - 关键优化:使用原生 ARM runner,无需 QEMU! + build-arm64: + runs-on: ubuntu-24.04-arm # GitHub 免费 ARM64 runner + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to GHCR + uses: docker/login-action@v3 + with: + registry: ${{ env.GHCR_REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + registry: ${{ env.DOCKERHUB_REGISTRY }} + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push ARM64 + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile + platforms: linux/arm64 + push: true + tags: | + ${{ env.GHCR_REGISTRY }}/${{ env.GHCR_IMAGE_NAME }}:${{ inputs.image_tag }}-arm64 + ${{ env.DOCKERHUB_REGISTRY }}/${{ env.DOCKERHUB_IMAGE_NAME }}:${{ inputs.image_tag }}-arm64 + # 分离的缓存作用域 + cache-from: type=gha,scope=arm64-${{ github.ref_name }} + cache-to: type=gha,mode=max,scope=arm64-${{ github.ref_name }} + + # 合并多架构 manifest + merge-manifests: + needs: [build-amd64, build-arm64] + runs-on: ubuntu-24.04 + steps: + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to GHCR + uses: docker/login-action@v3 + with: + registry: ${{ env.GHCR_REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + registry: ${{ env.DOCKERHUB_REGISTRY }} + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Create and push multi-arch manifests + run: | + # GHCR 多架构镜像 + docker buildx imagetools create \ + -t ${{ env.GHCR_REGISTRY }}/${{ env.GHCR_IMAGE_NAME }}:${{ inputs.image_tag }} \ + -t ${{ env.GHCR_REGISTRY }}/${{ env.GHCR_IMAGE_NAME }}:latest \ + ${{ env.GHCR_REGISTRY }}/${{ env.GHCR_IMAGE_NAME }}:${{ inputs.image_tag }}-amd64 \ + ${{ env.GHCR_REGISTRY }}/${{ env.GHCR_IMAGE_NAME }}:${{ inputs.image_tag }}-arm64 + + # Docker Hub 多架构镜像 + docker buildx imagetools create \ + -t ${{ env.DOCKERHUB_REGISTRY }}/${{ env.DOCKERHUB_IMAGE_NAME }}:${{ inputs.image_tag }} \ + -t ${{ env.DOCKERHUB_REGISTRY }}/${{ env.DOCKERHUB_IMAGE_NAME }}:latest \ + ${{ env.DOCKERHUB_REGISTRY }}/${{ env.DOCKERHUB_IMAGE_NAME }}:${{ inputs.image_tag }}-amd64 \ + ${{ env.DOCKERHUB_REGISTRY }}/${{ env.DOCKERHUB_IMAGE_NAME }}:${{ inputs.image_tag }}-arm64 + + - name: Generate summary + run: | + echo "### Docker Images Built and Pushed Successfully" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "**GHCR:** \`${{ env.GHCR_REGISTRY }}/${{ env.GHCR_IMAGE_NAME }}:${{ inputs.image_tag }}\`" >> $GITHUB_STEP_SUMMARY + echo "**Docker Hub:** \`${{ env.DOCKERHUB_REGISTRY }}/${{ env.DOCKERHUB_IMAGE_NAME }}:${{ inputs.image_tag }}\`" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "**Platforms:** linux/amd64, linux/arm64" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "### Pull Commands:" >> $GITHUB_STEP_SUMMARY + echo '```bash' >> $GITHUB_STEP_SUMMARY + echo "docker pull ${{ env.GHCR_REGISTRY }}/${{ env.GHCR_IMAGE_NAME }}:${{ inputs.image_tag }}" >> $GITHUB_STEP_SUMMARY + echo "docker pull ${{ env.DOCKERHUB_REGISTRY }}/${{ env.DOCKERHUB_IMAGE_NAME }}:${{ inputs.image_tag }}" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/ghcr-dockerhub.yml b/.github/workflows/ghcr-dockerhub.yml new file mode 100644 index 000000000..f129ffdc8 --- /dev/null +++ b/.github/workflows/ghcr-dockerhub.yml @@ -0,0 +1,119 @@ +name: Build and Push Multi-Arch Docker Images 2026.2.28同时推送镜像至ghcr和dockerhub + +on: + workflow_dispatch: + inputs: + image_tag: + description: 'Image tag version (e.g., v1.0.0, latest)' + required: true + default: 'latest' + +env: + GHCR_REGISTRY: ghcr.io + DOCKERHUB_REGISTRY: docker.io + # GitHub 仓库全名作为 GHCR 镜像名 + GHCR_IMAGE_NAME: ${{ github.repository }} + # Docker Hub 镜像名(需要根据实际情况设置) + DOCKERHUB_IMAGE_NAME: ${{ secrets.DOCKERHUB_USERNAME }}/${{ github.event.repository.name }} + +jobs: + build-and-push: + runs-on: ubuntu-24.04 + permissions: + contents: read + packages: write + id-token: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + driver-opts: | + image=moby/buildkit:master + network=host + + - name: Set up QEMU for multi-platform build + uses: docker/setup-qemu-action@v3 + + # 登录到 GHCR + - name: Log in to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ${{ env.GHCR_REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + # 登录到 Docker Hub(需要预先设置 secrets.DOCKERHUB_USERNAME 和 secrets.DOCKERHUB_TOKEN) + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + registry: ${{ env.DOCKERHUB_REGISTRY }} + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + # 为 GHCR 生成元数据 + - name: Extract metadata for GHCR + id: meta-ghcr + uses: docker/metadata-action@v5 + with: + images: ${{ env.GHCR_REGISTRY }}/${{ env.GHCR_IMAGE_NAME }} + tags: | + type=raw,value=${{ inputs.image_tag }} + type=raw,value=latest,enable=${{ inputs.image_tag != 'latest' }} + flavor: | + latest=true + + # 为 Docker Hub 生成元数据 + - name: Extract metadata for Docker Hub + id: meta-dockerhub + uses: docker/metadata-action@v5 + with: + images: ${{ env.DOCKERHUB_REGISTRY }}/${{ env.DOCKERHUB_IMAGE_NAME }} + tags: | + type=raw,value=${{ inputs.image_tag }} + type=raw,value=latest,enable=${{ inputs.image_tag != 'latest' }} + flavor: | + latest=true + + # 构建并推送多架构镜像到两个注册表 + - name: Build and push multi-arch images + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile + platforms: linux/amd64,linux/arm64 + push: true + tags: | + ${{ steps.meta-ghcr.outputs.tags }} + ${{ steps.meta-dockerhub.outputs.tags }} + labels: ${{ steps.meta-ghcr.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Generate summary + run: | + echo "### Docker Images Built and Pushed Successfully 🎉" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "**GitHub Container Registry (GHCR):**" >> $GITHUB_STEP_SUMMARY + echo "- Image: \`${{ env.GHCR_REGISTRY }}/${{ env.GHCR_IMAGE_NAME }}\`" >> $GITHUB_STEP_SUMMARY + echo "- Tags: ${{ inputs.image_tag }}${{ inputs.image_tag != 'latest' && ', latest' || '' }}" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "**Docker Hub:**" >> $GITHUB_STEP_SUMMARY + echo "- Image: \`${{ env.DOCKERHUB_REGISTRY }}/${{ env.DOCKERHUB_IMAGE_NAME }}\`" >> $GITHUB_STEP_SUMMARY + echo "- Tags: ${{ inputs.image_tag }}${{ inputs.image_tag != 'latest' && ', latest' || '' }}" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "**Platforms:** linux/amd64, linux/arm64" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "### Pull Commands:" >> $GITHUB_STEP_SUMMARY + echo "**GHCR:**" >> $GITHUB_STEP_SUMMARY + echo '```bash' >> $GITHUB_STEP_SUMMARY + echo "docker pull ${{ env.GHCR_REGISTRY }}/${{ env.GHCR_IMAGE_NAME }}:${{ inputs.image_tag }}" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "**Docker Hub:**" >> $GITHUB_STEP_SUMMARY + echo '```bash' >> $GITHUB_STEP_SUMMARY + echo "docker pull ${{ env.DOCKERHUB_REGISTRY }}/${{ env.DOCKERHUB_IMAGE_NAME }}:${{ inputs.image_tag }}" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY