1
0
mirror of https://github.com/pooneyy/1Panel-Appstore.git synced 2026-03-18 02:11:04 +08:00

feat(ci): Optimize Docker image build workflow

- Add new build-args parameter to support Dockerfile build parameter configuration
- Adjust parameter order and default values
This commit is contained in:
pooneyy 2025-10-03 04:17:00 +08:00
parent edea5329d5
commit 9ddf9c79c9
No known key found for this signature in database

View File

@ -4,42 +4,47 @@ on:
workflow_dispatch:
inputs:
repo:
description: '仓库地址'
description: 仓库地址
required: true
type: string
ref:
description: '分支名称'
description: 分支名称
required: true
type: string
image_name:
description: '镜像名称'
description: 镜像名称
required: true
type: string
image_tag:
description: '镜像标签'
description: 镜像标签
required: false
default: 'latest'
default: latest
type: string
build_target:
description: '构建目标'
dockerfile:
description: Dockerfile 在仓库中的路径
required: false
type: string
default: Dockerfile
architectures:
description: '构建架构'
description: 构建架构
required: false
type: string
default: "linux/amd64, linux/arm64, linux/arm/v7"
dockerfile:
description: 'Dockerfile 在仓库中的路径'
build_args:
description: 以空格分隔的列表,格式为`arg_name=value`用于定义Dockerfile中指定的构建参数
required: false
type: string
build_target:
description: 构建目标
required: false
type: string
default: 'Dockerfile'
env:
IMAGE_DESCRIPTION: Built by GitHub Actions, the associated workflow is https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
@ -56,13 +61,33 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Confirm current parameters
env:
REPO_URL: ${{ github.event.inputs.repo }}
TARGET_REF: ${{ github.event.inputs.ref }}
IMAGE_NAME: ${{ github.event.inputs.image_name }}
IMAGE_TAG: ${{ github.event.inputs.image_tag }}
DOCKERFILE: ${{ github.event.inputs.dockerfile }}
ARCHITECTURES: ${{ github.event.inputs.architectures }}
BUILD_ARGS: ${{ github.event.inputs.build_args }}
BUILD_TARGET: ${{ github.event.inputs.build_target }}
run: |
echo "REPO_URL=$REPO_URL"
echo "TARGET_REF=$TARGET_REF"
echo "IMAGE_NAME=$IMAGE_NAME"
echo "IMAGE_TAG=$IMAGE_TAG"
echo "DOCKERFILE=$DOCKERFILE"
echo "ARCHITECTURES=$ARCHITECTURES"
echo "BUILD_ARGS=$BUILD_ARGS"
echo "BUILD_TARGET=$BUILD_TARGET"
- name: Set env
env:
IMAGE_NAME=${{ github.event.inputs.image_name }}
IMAGE_NAME: ${{ github.event.inputs.image_name }}
run: |
owner=$(echo '${{ github.repository_owner }}' | tr '[:upper:]' '[:lower:]')
echo "OWNER=$owner" >> "$GITHUB_ENV"
echo "IMAGE_FULL_NAME=ghcr.io/${{ env.OWNER }}/$IMAGE_NAME" >> $GITHUB_ENV
echo "IMAGE_FULL_NAME=ghcr.io/$owner/$IMAGE_NAME" >> $GITHUB_ENV
echo "IMAGE_NAME=$IMAGE_NAME" >> $GITHUB_ENV
echo "IMAGE_TAG=${{ github.event.inputs.image_tag }}" >> $GITHUB_ENV
@ -135,6 +160,8 @@ jobs:
id: push
uses: docker/build-push-action@v6
with:
build-args: |
${{ github.event.inputs.repo }}
context: .
target: ${{ github.event.inputs.build_target }}
push: true