From 5e98b33939acb3d82f9c9c918c2d887ac314fe93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=A5=E6=B5=A9?= <37316281+yanhao98@users.noreply.github.com> Date: Tue, 8 Oct 2024 22:22:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95=20docker-build-push@main=20?= =?UTF-8?q?=E7=9A=84=20=E6=9E=84=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 2 ++ docker-build-push/Dockerfile | 1 + docker-build-push/action.yml | 30 +++++++++++++++++++++++------- 3 files changed, 26 insertions(+), 7 deletions(-) create mode 100644 docker-build-push/Dockerfile diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 654f5c7..9e6673a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,6 +22,8 @@ jobs: with: login_username: ${{ secrets.DOCKERHUB_USERNAME }} login_password: ${{ secrets.DOCKERHUB_TOKEN }} + build_push: false + build_file: ./docker-build-push/Dockerfile # - name: Check Docker image # run: | # set -x diff --git a/docker-build-push/Dockerfile b/docker-build-push/Dockerfile new file mode 100644 index 0000000..9d1491c --- /dev/null +++ b/docker-build-push/Dockerfile @@ -0,0 +1 @@ +FROM alpine:latest \ No newline at end of file diff --git a/docker-build-push/action.yml b/docker-build-push/action.yml index 10e2380..e2a450a 100644 --- a/docker-build-push/action.yml +++ b/docker-build-push/action.yml @@ -4,13 +4,29 @@ inputs: login_repository: description: "docker/login-action 的 registry 参数" default: "docker.io" - required: true + required: false login_username: description: "docker/login-action 的 username 参数" required: true login_password: description: "docker/login-action 的 password 参数" required: true + build_file: + description: "Dockerfile 文件路径" + default: "./Dockerfile" + required: false + build_context: + description: "Docker 构建上下文路径" + default: "." + required: false + build_platforms: + description: "Docker 构建平台" + default: "linux/amd64,linux/arm64" + required: false + build_push: + description: "是否推送 Docker 镜像" + default: "true" + required: false runs: using: "composite" steps: @@ -31,11 +47,11 @@ runs: - name: Build and push uses: docker/build-push-action@v6 with: - context: . - platforms: linux/amd64,linux/arm64 - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - file: ./Dockerfile + file: ${{ inputs.build_file }} + context: ${{ inputs.build_context }} + platforms: ${{ inputs.build_platforms }} + push: ${{ inputs.build_push }} + # tags: ${{ steps.meta.outputs.tags }} + # labels: ${{ steps.meta.outputs.labels }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache \ No newline at end of file