first
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
# dp-report
|
||||
|
||||
把镜像记录到部署平台:下载并执行平台的 `scripts/push-image` 脚本。
|
||||
|
||||
`server` 只填域名,action 会补上 `/api/sdp`,实际执行:
|
||||
|
||||
```
|
||||
curl -fsSL <server>/api/sdp/scripts/push-image | bash -s -- --token <token> --image <registry>/<image> --server <server>/api/sdp
|
||||
```
|
||||
|
||||
## 参数
|
||||
|
||||
| 参数 | 必填 | 默认值 | 说明 |
|
||||
| --- | --- | --- | --- |
|
||||
| `server` | 否 | `https://auth.coce.cc` | 部署平台地址,只填域名 |
|
||||
| `token` | 否 | `${{ secrets.DEPLOY_PLATFORM_TOKEN }}` | 部署平台 TOKEN |
|
||||
| `registry` | 否 | `${{ vars.DOCKER_REGISTRY }}` | 镜像 registry,可替换 |
|
||||
| `image` | 否 | `${{ github.repository }}` | 镜像名,不含 registry |
|
||||
|
||||
最终传给脚本的镜像是 `<registry>/<image>`;如果 `registry` 留空,则直接使用 `image`。`image` 里可以带 tag。
|
||||
|
||||
> `token` 默认取 `secrets.DEPLOY_PLATFORM_TOKEN`;如果你的 runner 不支持在 composite action 的 input 默认值里使用 `secrets`,调用时显式传 `token: ${{ secrets.DEPLOY_PLATFORM_TOKEN }}` 即可。
|
||||
|
||||
## 示例
|
||||
|
||||
```yaml
|
||||
- uses: actions/dp-report@main
|
||||
```
|
||||
|
||||
替换 registry / image:
|
||||
|
||||
```yaml
|
||||
- uses: actions/dp-report@main
|
||||
with:
|
||||
registry: registry.example.com
|
||||
image: simcu/web
|
||||
```
|
||||
|
||||
替换服务器地址:
|
||||
|
||||
```yaml
|
||||
- uses: actions/dp-report@main
|
||||
with:
|
||||
server: https://auth.example.com
|
||||
```
|
||||
|
||||
显式传 token(默认值不可用时):
|
||||
|
||||
```yaml
|
||||
- uses: actions/dp-report@main
|
||||
with:
|
||||
token: ${{ secrets.DEPLOY_PLATFORM_TOKEN }}
|
||||
```
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
# 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"
|
||||
Reference in New Issue
Block a user