Files
woodpecker-rustfs/example/linux/woodpecker.yml
lingyuzeng b9c900b9b1
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
完整配置参考
2025-10-12 18:43:31 +08:00

104 lines
3.1 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.yml
labels:
platform: linux/amd64
when:
event: [push, manual]
steps:
# 第一步:构建项目(示例)
- name: build
image: node:18-alpine
commands:
- echo "Building project..."
- mkdir -p dist/assets
- echo '<!DOCTYPE html><html><body><h1>Hello World</h1></body></html>' > dist/index.html
- echo 'body { font-family: Arial; }' > dist/assets/style.css
- echo 'console.log("App loaded");' > dist/assets/app.js
- echo "Build complete!"
- ls -R dist/
# 第二步:上传单个日志文件
- name: upload-build-log
image: alpine:latest
environment:
AWS_ACCESS_KEY_ID:
from_secret: AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY:
from_secret: AWS_SECRET_ACCESS_KEY
S3_BUCKET:
from_secret: S3_BUCKET
S3_ENDPOINT:
from_secret: S3_ENDPOINT
commands:
- |
# 安装 plugin-s3如果镜像中没有
# 或使用已安装的镜像
# 创建构建日志
date > build.log
echo "Build completed successfully" >> build.log
# 上传日志文件
export PLUGIN_SOURCE="build.log"
export PLUGIN_BUCKET="$S3_BUCKET"
export PLUGIN_TARGET="logs/build-${CI_COMMIT_SHA:0:8}.log"
export PLUGIN_ENDPOINT="$S3_ENDPOINT"
export PLUGIN_PATH_STYLE=true
plugin-s3
echo "✅ Build log uploaded to s3://$S3_BUCKET/logs/"
# 第三步:上传整个 dist 文件夹
- name: upload-dist-folder
image: alpine:latest
environment:
AWS_ACCESS_KEY_ID:
from_secret: AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY:
from_secret: AWS_SECRET_ACCESS_KEY
S3_BUCKET:
from_secret: S3_BUCKET
S3_ENDPOINT:
from_secret: S3_ENDPOINT
commands:
- |
# 上传整个 dist 目录
export PLUGIN_SOURCE="dist/**/*"
export PLUGIN_BUCKET="$S3_BUCKET"
export PLUGIN_TARGET="website/${CI_COMMIT_BRANCH}/"
export PLUGIN_ENDPOINT="$S3_ENDPOINT"
export PLUGIN_PATH_STYLE=true
export PLUGIN_STRIP_PREFIX="dist/"
export PLUGIN_ACL="public-read"
plugin-s3
echo "✅ Website deployed to s3://$S3_BUCKET/website/${CI_COMMIT_BRANCH}/"
# 第四步:上传构建产物(压缩包)
- name: upload-artifacts
image: alpine:latest
environment:
AWS_ACCESS_KEY_ID:
from_secret: AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY:
from_secret: AWS_SECRET_ACCESS_KEY
S3_BUCKET:
from_secret: S3_BUCKET
S3_ENDPOINT:
from_secret: S3_ENDPOINT
commands:
- |
# 创建压缩包
apk add --no-cache zip
zip -r dist-${CI_COMMIT_SHA:0:8}.zip dist/
# 上传压缩包
export PLUGIN_SOURCE="dist-*.zip"
export PLUGIN_BUCKET="$S3_BUCKET"
export PLUGIN_TARGET="releases/${CI_COMMIT_BRANCH}/"
export PLUGIN_ENDPOINT="$S3_ENDPOINT"
export PLUGIN_PATH_STYLE=true
plugin-s3
echo "✅ Artifacts uploaded to s3://$S3_BUCKET/releases/${CI_COMMIT_BRANCH}/"