demo/.woodpecker.yaml

63 lines
2.3 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# .woodpecker.yaml
steps:
- name: Java 构建
image: docker.m.daocloud.io/library/maven:3.9.6-eclipse-temurin-17
pull: true
commands:
- mvn clean package -DskipTests
# 注意:使用 volumes 必须在 Web UI 中开启 "Trusted" 权限
volumes:
- /tmp/maven-cache:/root/.m2
when:
event: [push, pull_request]
branch: master
- name: 镜像构建与推送
image: docker.m.daocloud.io/woodpeckerci/plugin-docker-buildx:latest
volumes:
- /var/run/docker.sock:/var/run/docker.sock
settings:
repo: registry.cn-zhangjiakou.aliyuncs.com/abhors/demo
tags: latest
registry: registry.cn-zhangjiakou.aliyuncs.com
username:
from_secret: aliyun_acr_username
password:
from_secret: aliyun_acr_password
# 👇 核心:为其指定一个绝对能稳定拉取三方大类目的镜像加速源
# 这样当它去找 moby/buildkit 时会自动走大厂的代理通道100% 不会超时
mirror: https://docker.m.daocloud.io
# 很多时候 plugins/docker 内部默认会处理 context不需要你手动挂载 docker.sock
# 但需要确保服务器配置了 WOODPECKER_PLUGINS_PRIVILEGED=plugins/docker
when:
event: push
branch: master
- name: 远程 Docker Compose 部署
image: docker.m.daocloud.io/appleboy/drone-docker-compose:latest
settings:
# 1. 远程 136 服务器的信息(直接从你的 Secret 里读,插件自己会去连 22 端口,不需要你开 2375 端口了!)
host:
from_secret: 136_ssh_host
username:
from_secret: 136_ssh_user
password:
from_secret: 136_ssh_password
port: 22
# 2. 阿里云私有镜像仓库的鉴权(插件在远程拉取前,会自动在远程帮你搞定 docker login
registry: registry.cn-zhangjiakou.aliyuncs.com
username_registry:
from_secret: aliyun_acr_username
password_registry:
from_secret: aliyun_acr_password
# 3. 告诉插件:你的 docker-compose.yaml 文件在哪里(它会自动读取并同步到远程执行)
compose: docker-compose.yaml
# 4. 相当于执行 docker compose up -d --pull --force-recreate
pull: true
recreate:
true
when:
event: [push, pull_request]
branch: master