Compare commits

..

2 Commits

Author SHA1 Message Date
necobot d74521a76a ci: build and publish text-mosaic latest image 2026-10-10 23:38:17 +08:00
mattuy 70976ff03a recreate project 2026-08-01 11:53:13 +08:00
+6 -74
View File
@@ -1,58 +1,12 @@
# 文字马赛克静态站镜像构建流水线 labels:
# 触发:push 到 main 自动运行,也支持手动运行。 platform: linux/amd64
# 镜像:registry.mattuy.top/text-mosaic:<sha7>
when: when:
- event: push - event: push
branch: main branch: main
- event: manual - event: manual
variables:
- &notify_image registry.gitlab.com/gitlab-ci-utils/curl-jq:4.0.2
- &small_resources
requests:
cpu: "10m"
memory: "32Mi"
limits:
cpu: "200m"
memory: "128Mi"
- &notify_script |
case "$NOTIFY_EVENT" in
started) EMOJI="🚀"; TEXT="静态站镜像构建开始" ;;
success) EMOJI="✅"; TEXT="静态站镜像构建成功" ;;
failure) EMOJI="❌"; TEXT="静态站镜像构建失败" ;;
*) EMOJI="❓"; TEXT="$NOTIFY_EVENT" ;;
esac
COMMIT_SHORT=$(printf '%s' "$CI_COMMIT_SHA" | cut -c1-7)
COMMIT_SUBJECT=$(printf '%s' "$CI_COMMIT_MESSAGE" | head -1)
TITLE="$EMOJI [text-mosaic] $TEXT"
CONTENT="分支: $CI_COMMIT_BRANCH
提交: $COMMIT_SHORT \"$COMMIT_SUBJECT\"
作者: $CI_COMMIT_AUTHOR
详情: $CI_PIPELINE_URL"
PAYLOAD=$(jq -n -c \
--arg source 'text-mosaic' \
--arg title "$TITLE" \
--arg content "$CONTENT" \
--arg priority "$NOTIFY_PRIORITY" \
'{source: $source, title: $title, content: $content} + (if $priority == "" then {} else {priority: $priority} end)')
curl -sS --fail-with-body --show-error -X POST -H 'content-type: application/json' \
-d "$PAYLOAD" \
http://mattuy-api.mattuy-house.svc/api/notification/notify
steps: steps:
notify-start:
image: *notify_image
environment:
NOTIFY_EVENT: started
NOTIFY_PRIORITY: silent
backend_options:
kubernetes:
resources: *small_resources
commands:
- *notify_script
failure: ignore
build-and-push: build-and-push:
image: moby/buildkit:v0.28.1 image: moby/buildkit:v0.28.1
backend_options: backend_options:
@@ -70,31 +24,9 @@ steps:
--frontend dockerfile.v0 --frontend dockerfile.v0
--local context=. --local context=.
--local dockerfile=. --local dockerfile=.
--output type=image,\"name=registry.mattuy.top/text-mosaic:${CI_COMMIT_SHA:0:7}\",push=true,registry.insecure=true --opt build-arg:http_proxy=http://mihomo.mattuy-house.svc:7890
--opt build-arg:https_proxy=http://mihomo.mattuy-house.svc:7890
--opt build-arg:no_proxy=localhost,127.0.0.1,.mattuy-house.svc,.svc,.cluster.local,registry.mattuy.top,mirror.mattuy.top,io-lan.mattuy.top
--output type=image,"name=registry.mattuy.top/text-mosaic:${CI_COMMIT_SHA:0:7},registry.mattuy.top/text-mosaic:latest",push=true,registry.insecure=true
--export-cache type=s3,mode=max,bucket=buildcache,region=us-east-1,endpoint_url=https://io-lan.mattuy.top,use_path_style=true,name=text-mosaic --export-cache type=s3,mode=max,bucket=buildcache,region=us-east-1,endpoint_url=https://io-lan.mattuy.top,use_path_style=true,name=text-mosaic
--import-cache type=s3,bucket=buildcache,region=us-east-1,endpoint_url=https://io-lan.mattuy.top,use_path_style=true,name=text-mosaic --import-cache type=s3,bucket=buildcache,region=us-east-1,endpoint_url=https://io-lan.mattuy.top,use_path_style=true,name=text-mosaic
notify-success:
image: *notify_image
environment:
NOTIFY_EVENT: success
NOTIFY_PRIORITY: low
backend_options:
kubernetes:
resources: *small_resources
commands:
- *notify_script
failure: ignore
notify-failure:
image: *notify_image
environment:
NOTIFY_EVENT: failure
backend_options:
kubernetes:
resources: *small_resources
commands:
- *notify_script
when:
- status: failure
failure: ignore