feat(ci): allow custom wasm plugin image name via .buildrc (#4053)

Signed-off-by: CH3CHO <ch3cho@qq.com>
This commit is contained in:
Kent Dong
2026-07-16 14:41:15 +08:00
committed by GitHub
parent afb72b81cb
commit 58773cb98e
9 changed files with 29 additions and 5 deletions

View File

@@ -104,11 +104,6 @@ jobs:
push_command=${push_command#\"}
push_command=${push_command%\"} # 删除PUSH_COMMAND中的双引号确保oras push正常解析
target_image="${{ env.IMAGE_REGISTRY_SERVICE }}/${{ env.IMAGE_REPOSITORY}}/${{ env.PLUGIN_NAME }}:${{ env.VERSION }}"
target_image_latest="${{ env.IMAGE_REGISTRY_SERVICE }}/${{ env.IMAGE_REPOSITORY}}/${{ env.PLUGIN_NAME }}:latest"
echo "TargetImage=${target_image}"
echo "TargetImageLatest=${target_image_latest}"
cd ${{ github.workspace }}/plugins/wasm-${PLUGIN_TYPE}/extensions/${PLUGIN_NAME}
if [ -f ./.buildrc ]; then
echo 'Found .buildrc file, sourcing it...'
@@ -116,6 +111,21 @@ jobs:
else
echo '.buildrc file not found'
fi
# Resolve custom image short name from .buildrc, fallback to plugin directory name.
# .buildrc may define IMAGE_NAME=xxx to override the output image tag.
IMAGE_NAME=${IMAGE_NAME:-$PLUGIN_NAME}
if ! [[ "$IMAGE_NAME" =~ ^[a-z0-9._-]+$ ]]; then
echo "::error::Invalid IMAGE_NAME '$IMAGE_NAME' in .buildrc — must match [a-z0-9._-]+"
exit 1
fi
echo "IMAGE_NAME=${IMAGE_NAME}"
target_image="${{ env.IMAGE_REGISTRY_SERVICE }}/${{ env.IMAGE_REPOSITORY}}/${IMAGE_NAME}:${{ env.VERSION }}"
target_image_latest="${{ env.IMAGE_REGISTRY_SERVICE }}/${{ env.IMAGE_REPOSITORY}}/${IMAGE_NAME}:latest"
echo "TargetImage=${target_image}"
echo "TargetImageLatest=${target_image_latest}"
echo "EXTRA_TAGS=${EXTRA_TAGS}"
if [ "${PLUGIN_TYPE}" == "go" ]; then
command="

View File

@@ -11,6 +11,10 @@
```bash
# NOTE: 如果你想在构建插件的时候设置额外的构建参数 EXTRA_TAGS
# 请更新 extensions/${PLUGIN_NAME} 插件目录对应的 .buildrc 文件
# NOTE: 如果你想自定义最终推送的镜像短名(覆盖默认的插件目录名),
# 可以在 .buildrc 中添加 IMAGE_NAME=<your-image-name>。
# 镜像短名只能包含小写字母、数字、`.`、`_`、`-`,否则构建会失败。
# 本设置仅影响推送的镜像 tag不影响源码路径。
$ PLUGIN_NAME=request-block make build
```

View File

@@ -9,6 +9,10 @@ The wasm-go plugin can be built quickly with the following command:
```bash
# NOTE: if you want to set EXTRA_TAGS for the wasm plugin
# please set them in the .buildrc file under extensions/${PLUGIN_NAME} directory
# NOTE: to override the output image short name (default: plugin directory name),
# add `IMAGE_NAME=<your-image-name>` to .buildrc.
# The image name must contain only [a-z0-9._-], or the build will fail.
# This affects the pushed image tag only, not the source code path.
$ PLUGIN_NAME=request-block make build
```

View File

@@ -0,0 +1 @@
IMAGE_NAME=go-basic-auth

View File

@@ -0,0 +1 @@
IMAGE_NAME=go-bot-detect

View File

@@ -0,0 +1 @@
IMAGE_NAME=go-custom-response

View File

@@ -0,0 +1 @@
IMAGE_NAME=go-jwt-auth

View File

@@ -0,0 +1 @@
IMAGE_NAME=go-key-auth

View File

@@ -0,0 +1 @@
IMAGE_NAME=go-sni-misdirect