添加 .github/workflows/build.yaml
This commit is contained in:
61
.github/workflows/build.yaml
vendored
Normal file
61
.github/workflows/build.yaml
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
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 }}
|
||||
Reference in New Issue
Block a user