refactor(ci): 优化 Woodpecker CI 配置

- 移除 Maven 缓存卷挂载配置
- 更新 Docker 构建步骤为镜像构建与推送
- 使用 plugins/docker 插件简化 Docker 操作
- 添加条件触发规则仅在 main 分支 push 时执行
- 注释说明 plugins/docker 插件权限配置要求
This commit is contained in:
gxl 2026-06-02 13:54:24 +08:00
parent cc3a740993
commit 1d3b08c306
1 changed files with 11 additions and 11 deletions

View File

@ -5,19 +5,14 @@ steps:
pull: true pull: true
commands: commands:
- mvn clean package -DskipTests - mvn clean package -DskipTests
# volumes 挂载在单工作流中可正常使用 # 注意:使用 volumes 必须在 Web UI 中开启 "Trusted" 权限
volumes: volumes:
- /tmp/maven-cache:/root/.m2 - /tmp/maven-cache:/root/.m2
when:
event: [push, pull_request]
branch: main
- name: Docker 构建 - name: 镜像构建与推送
image: docker:latest
pull: true
commands:
- docker build -t registry.cn-zhangjiakou.aliyuncs.com/abhors/demo:latest .
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- name: 镜像推送
image: plugins/docker image: plugins/docker
settings: settings:
repo: registry.cn-zhangjiakou.aliyuncs.com/abhors/demo repo: registry.cn-zhangjiakou.aliyuncs.com/abhors/demo
@ -27,3 +22,8 @@ steps:
from_secret: aliyun_acr_username from_secret: aliyun_acr_username
password: password:
from_secret: aliyun_acr_password from_secret: aliyun_acr_password
# 很多时候 plugins/docker 内部默认会处理 context不需要你手动挂载 docker.sock
# 但需要确保服务器配置了 WOODPECKER_PLUGINS_PRIVILEGED=plugins/docker
when:
event: push
branch: main