name: Virtual Kubelet Docker Build and Deploy on: push: tags: - 'v*' jobs: build-and-deploy: runs-on: ubuntu-latest steps: - run: echo "🎉 该作业由 ${{ gitea.event_name }} 事件自动触发。" - run: echo "🐧 此作业当前在 Gitea 托管的 ${{ runner.os }} 服务器上运行!" - run: echo "🔎 您的标签名称是 ${{ gitea.ref_name }},仓库是 ${{ gitea.repository }}。" - name: 检出仓库代码 uses: https://gitee.com/zyh320888/checkout@v4 - run: echo "💡 ${{ gitea.repository }} 仓库已克隆到运行器。" - run: echo "🖥️ 工作流现在已准备好在运行器上测试您的代码。" - name: 列出仓库中的文件 run: | ls -la ${{ gitea.workspace }} - run: echo "🍏 此作业的状态是 ${{ job.status }}。" - name: 设置 Docker Buildx 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: | # 从标签名中提取版本号,例如从 v0.1.0 中提取 v0.1.0 VERSION=$(echo "${{ gitea.ref_name }}") echo "VERSION=$VERSION" >> $GITHUB_ENV echo "提取的版本号:$VERSION" - name: 登录 Docker 注册表 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: https://gitee.com/zyh320888/build-push-action@v5 with: context: . 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="" labels: | org.opencontainers.image.title=Virtual Kubelet org.opencontainers.image.description=Kubernetes Virtual Kubelet implementation org.opencontainers.image.version=${{ env.VERSION }} org.opencontainers.image.source=${{ gitea.repositoryUrl }} org.opencontainers.image.revision=${{ gitea.sha }}