Files
dp-report/action.yml
T
2026-10-21 17:10:30 +08:00

65 lines
1.8 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.
# action.yml
name: "dp report"
description: "调用部署平台记录镜像(push-image 脚本)"
inputs:
server:
description: "部署平台地址,只填域名(脚本和 API 在 /api/sdp 下)"
required: false
default: "https://auth.coce.cc"
token:
description: "部署平台 TOKEN,默认取 secrets.DEPLOY_PLATFORM_TOKEN"
required: false
default: "${{ secrets.DEPLOY_PLATFORM_TOKEN }}"
registry:
description: "镜像 registry,默认 vars.DOCKER_REGISTRY,可替换"
required: false
default: "${{ vars.DOCKER_REGISTRY }}"
image:
description: "镜像名,不含 registry(默认 github.repository)"
required: false
default: "${{ github.repository }}"
runs:
using: "composite"
steps:
- name: push image record
shell: bash
env:
SERVER: ${{ inputs.server }}
TOKEN: ${{ inputs.token }}
REGISTRY: ${{ inputs.registry }}
IMAGE_NAME: ${{ inputs.image }}
run: |
set -euo pipefail
server="${SERVER%/}"
if [ -z "$server" ]; then
echo "缺少 server(部署平台地址)"
exit 1
fi
# 平台脚本和 API 都在 /api/sdp 下
api="$server/api/sdp"
if [ -z "${TOKEN:-}" ]; then
echo "缺少 token(部署平台 TOKEN)"
exit 1
fi
if [ -z "${IMAGE_NAME:-}" ]; then
echo "缺少 image(镜像名)"
exit 1
fi
if [ -n "${REGISTRY:-}" ]; then
image="${REGISTRY%/}/${IMAGE_NAME}"
else
image="$IMAGE_NAME"
fi
echo "server: $api"
echo "image: $image"
curl -fsSL "$api/scripts/push-image" | bash -s -- \
--token "$TOKEN" \
--image "$image" \
--server "$api"