From 63c8d4dd3d15c30d16f4dbe1a1aab09bbad74e4b Mon Sep 17 00:00:00 2001 From: D8D Developer Date: Fri, 2 Jan 2026 01:01:45 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=B7=20ci(workflow):=20=E9=80=82?= =?UTF-8?q?=E9=85=8D=20Gitea=20Actions=20=E5=B9=B6=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E6=9E=84=E5=BB=BA=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除对 GitHub Actions 的 `pull_request` 触发器,仅保留标签推送触发 - 将所有 GitHub Actions 官方引用替换为对应的 Gitea 镜像仓库地址 - 将工作流上下文变量从 `github.*` 统一更新为 `gitea.*` - 优化步骤结构,将部分 `run` 命令合并为独立步骤以提高可读性 - 在 Docker Buildx 设置步骤中,显式指定构建器驱动镜像和网络配置 - 在构建并推送镜像步骤中,为镜像标签添加基于提取版本号的动态标签 - 更新容器镜像元数据中的源代码和修订版本信息源为 Gitea --- .github/workflows/build.yaml | 50 +++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index ef7a74a..7a4482f 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -3,54 +3,58 @@ on: push: tags: - 'v*' - pull_request: jobs: build-and-deploy: runs-on: ubuntu-latest steps: - - name: 输出触发信息 - run: | - echo "🎉 该作业由 ${{ github.event_name }} 事件自动触发。" - echo "🐧 此作业当前在 GitHub 托管的 ${{ runner.os }} 服务器上运行!" - echo "🔎 您的发布版本是 ${{ github.ref_name }},仓库是 ${{ github.repository }}。" + - run: echo "🎉 该作业由 ${{ gitea.event_name }} 事件自动触发。" + - run: echo "🐧 此作业当前在 Gitea 托管的 ${{ runner.os }} 服务器上运行!" + - run: echo "🔎 您的标签名称是 ${{ gitea.ref_name }},仓库是 ${{ gitea.repository }}。" - name: 检出仓库代码 - uses: actions/checkout@v4 + uses: https://gitee.com/zyh320888/checkout@v4 - - name: 输出工作区信息 + - run: echo "💡 ${{ gitea.repository }} 仓库已克隆到运行器。" + - run: echo "🖥️ 工作流现在已准备好在运行器上测试您的代码。" + + - name: 列出仓库中的文件 run: | - echo "💡 ${{ github.repository }} 仓库已克隆到运行器。" - echo "🖥️ 工作流现在已准备好在运行器上测试您的代码。" - ls -la ${{ github.workspace }} - echo "🍏 此作业的状态是 ${{ job.status }}。" + ls -la ${{ gitea.workspace }} + + - run: echo "🍏 此作业的状态是 ${{ job.status }}。" - name: 设置 Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: 从标签名中提取版本号 + uses: https://gitee.com/zyh320888/setup-buildx-action@v3 + with: + driver-opts: | + image=docker.1ms.run/moby/buildkit:master + network=host + + - name: 提取版本号 id: extract_version run: | - # 从Release标签名中提取版本号,例如从 v0.1.0 中提取 v0.1.0 - VERSION=$(echo "${{ github.ref_name }}" | sed 's|refs/tags/||') + # 从标签名中提取版本号,例如从 v0.1.0 中提取 v0.1.0 + VERSION=$(echo "${{ gitea.ref_name }}") echo "VERSION=$VERSION" >> $GITHUB_ENV echo "提取的版本号:$VERSION" - + - name: 登录 Docker 注册表 - uses: docker/login-action@v3 + uses: https://gitee.com/zyh320888/login-action@v3 with: registry: registry.cn-beijing.aliyuncs.com username: ${{ secrets.ALI_DOCKER_REGISTRY_USERNAME }} password: ${{ secrets.ALI_DOCKER_REGISTRY_PASSWORD }} - name: 构建并推送 Virtual Kubelet 镜像 - uses: docker/build-push-action@v5 + uses: https://gitee.com/zyh320888/build-push-action@v5 with: context: . - file: ./Dockerfile # 确保Dockerfile路径正确 + file: ./Dockerfile push: true tags: | registry.cn-beijing.aliyuncs.com/d8dcloud/virtual-kubelet:eci-alpine + registry.cn-beijing.aliyuncs.com/d8dcloud/virtual-kubelet:${{ env.VERSION }} build-args: | GOLANG_CI_LINT_VERSION=v1.68.0 BUILD_TAGS="" @@ -58,5 +62,5 @@ jobs: org.opencontainers.image.title=Virtual Kubelet org.opencontainers.image.description=Kubernetes Virtual Kubelet implementation org.opencontainers.image.version=${{ env.VERSION }} - org.opencontainers.image.source=${{ github.repositoryUrl }} - org.opencontainers.image.revision=${{ github.sha }} \ No newline at end of file + org.opencontainers.image.source=${{ gitea.repositoryUrl }} + org.opencontainers.image.revision=${{ gitea.sha }}