Files
virtual-kubelet/.github/workflows/build.yaml
d8dfun d2a043f2a3
Some checks failed
CI / Lint (push) Has started running
CI / Unit Tests (push) Has been cancelled
CI / Envtest Tests (push) Has been cancelled
CI / E2E (push) Has been cancelled
CodeQL / Analyze (go) (push) Has been cancelled
添加 .github/workflows/build.yaml
2025-07-01 00:19:14 +00:00

61 lines
2.5 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

name: Virtual Kubelet Docker Build and Deploy
on:
release:
types: [created] # 仅在创建Release时触发也可选择published、edited等
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 }}。"
- name: 检出仓库代码
uses: actions/checkout@v4
- name: 输出工作区信息
run: |
echo "💡 ${{ github.repository }} 仓库已克隆到运行器。"
echo "🖥️ 工作流现在已准备好在运行器上测试您的代码。"
ls -la ${{ github.workspace }}
echo "🍏 此作业的状态是 ${{ job.status }}。"
- name: 设置 Docker Buildx
uses: docker/setup-buildx-action@v3
- name: 从标签名中提取版本号
id: extract_version
run: |
# 从Release标签名中提取版本号例如从 v0.1.0 中提取 v0.1.0
VERSION=$(echo "${{ github.ref_name }}" | sed 's|refs/tags/||')
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "提取的版本号:$VERSION"
- name: 登录 Docker 注册表
uses: docker/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
with:
context: .
file: ./Dockerfile # 确保Dockerfile路径正确
push: true
tags: |
registry.cn-beijing.aliyuncs.com/d8dcloud/virtual-kubelet:${{ env.VERSION }}
registry.cn-beijing.aliyuncs.com/d8dcloud/virtual-kubelet:latest
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=${{ github.repositoryUrl }}
org.opencontainers.image.revision=${{ github.sha }}