mirror of
https://github.com/lkddi/dell-fans-controller-docker.git
synced 2026-04-03 18:10:51 +08:00
添加GitHub Actions自动构建Docker镜像工作流
- 创建了自动构建和推送Docker镜像的GitHub Actions工作流 - 支持多架构构建 (linux/amd64, linux/arm64) - 自动推送到Docker Hub和阿里云容器镜像服务 - 更新Dockerfile以优化构建过程 - 更新README.md包含Docker镜像信息
This commit is contained in:
58
.github/workflows/docker-build.yml
vendored
Normal file
58
.github/workflows/docker-build.yml
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
name: Build and Push Docker Image
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v2
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
|
||||
- name: Login to DockerHub
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Login to Alibaba Cloud Container Registry
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
registry: registry.cn-huhehaote.aliyuncs.com
|
||||
username: ${{ secrets.ALIBABA_USERNAME }}
|
||||
password: ${{ secrets.ALIBABA_PASSWORD }}
|
||||
|
||||
- name: Extract metadata (tags, labels) for Docker
|
||||
id: meta
|
||||
uses: docker/metadata-action@v4
|
||||
with:
|
||||
images: |
|
||||
joestar817/dell-fans-controller-docker
|
||||
registry.cn-huhehaote.aliyuncs.com/lkddi_image/dell-fans-controller-docker
|
||||
tags: |
|
||||
type=ref,event=branch
|
||||
type=ref,event=pr
|
||||
type=sha,prefix={{branch}}-
|
||||
latest
|
||||
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
context: .
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
Reference in New Issue
Block a user