Files
website/.gitea/workflows/probe-visibility.yml
T
技小云 93fced52b9
mirror-to-gitee / mirror (push) Successful in 5s
chore: 探测建仓可见性参数与删仓权限(临时)
2026-11-04 11:24:04 +08:00

59 lines
2.4 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.
name: probe-visibility
# 一次性排查:验证 Gitee 企业仓「建仓时指定 private:false」是否直接得到公开仓,
# 以及该令牌是否具备删仓权限。只在临时仓 __probe_vis 上操作。
on:
workflow_dispatch:
jobs:
probe:
runs-on: host
steps:
- name: 验证建仓可见性参数与删仓权限
env:
DST_TOKEN: ${{ secrets.GITEE_TOKEN }}
DST_OWNER: ${{ secrets.GITEE_OWNER }}
run: |
set -u
NAME="__probe_vis"
echo "=== 1. 建仓(private:false + internal:false) ==="
curl -sS -m 25 -X POST \
"https://gitee.com/api/v5/enterprises/${DST_OWNER}/repos?access_token=${DST_TOKEN}" \
-H 'Content-Type: application/json' \
-d "{\"name\":\"${NAME}\",\"auto_init\":false,\"private\":false,\"internal\":false,\"description\":\"临时探测仓\"}" \
-o /tmp/create.json -w '建仓 HTTP %{http_code}\n' || true
python3 - <<'PY'
import json
try:
d = json.load(open('/tmp/create.json'))
except Exception:
print('parse fail'); raise SystemExit
if 'message' in d:
print('message:', d.get('message'))
else:
print('path:', d.get('path'), '| private:', d.get('private'), '| internal:', d.get('internal'))
PY
echo "=== 2. 匿名可见性(200=公开) ==="
curl -s -o /dev/null -w "匿名 ${NAME}: HTTP %{http_code}\n" -m 20 "https://gitee.com/${DST_OWNER}/${NAME}"
echo "=== 3. 删临时仓 ==="
curl -sS -m 25 -X DELETE \
"https://gitee.com/api/v5/repos/${DST_OWNER}/${NAME}?access_token=${DST_TOKEN}" \
-o /tmp/del.json -w '删仓 HTTP %{http_code}\n' || true
head -c 200 /tmp/del.json 2>/dev/null; echo
echo "=== 4. 正式仓 website 当前可见性 ==="
curl -sS -m 20 "https://gitee.com/api/v5/repos/${DST_OWNER}/website?access_token=${DST_TOKEN}" -o /tmp/w.json
python3 - <<'PY'
import json
d = json.load(open('/tmp/w.json'))
if 'message' in d:
print('message:', d.get('message'))
else:
for k in ('path', 'private', 'internal', 'public', 'visibility'):
print(k, '=', d.get(k))
PY
curl -s -o /dev/null -w "匿名 website: HTTP %{http_code}\n" -m 20 "https://gitee.com/${DST_OWNER}/website"