chore: 探测建仓可见性参数与删仓权限(临时)
mirror-to-gitee / mirror (push) Successful in 4s

This commit is contained in:
技小云
2026-11-04 11:22:30 +08:00
committed by MiFaZhan
parent d28be419b5
commit 4200e0fc53
+34 -25
View File
@@ -1,7 +1,8 @@
name: probe-visibility
# 一次性排查:Gitee 端仓的可见性当前值,以及公开仓/私有仓的字段差异。
# 只读探测,不做修改。
# 一次性排查:验证 Gitee 企业仓「建仓时指定 private:false」是否直接得到公开仓,
# 以及该令牌是否具备删仓权限。
# 只在临时仓 __probe_vis 上操作,不动正式仓。
on:
workflow_dispatch:
@@ -9,42 +10,50 @@ jobs:
probe:
runs-on: host
steps:
- name: 对比公开仓与门户仓的可见性字段
- name: 验证建仓可见性参数与删仓权限
env:
DST_TOKEN: ${{ secrets.GITEE_TOKEN }}
DST_OWNER: ${{ secrets.GITEE_OWNER }}
run: |
set -u
for NAME in iotlcm xiu-dtu website; do
echo "=== $NAME ==="
curl -sS -m 20 "https://gitee.com/api/v5/repos/${DST_OWNER}/${NAME}?access_token=${DST_TOKEN}" \
| python3 -c "
import sys, json
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 -c "
import json
try:
d = json.load(sys.stdin)
d = json.load(open('/tmp/create.json'))
except Exception:
print('parse fail'); raise SystemExit
if 'message' in d:
print('message:', d.get('message'))
else:
for k in ('path','private','internal','public','visibility','open_issue','owner'):
v = d.get(k)
if isinstance(v, dict):
v = v.get('login') or v.get('name')
print(f'{k}: {v}')
print('path:', d.get('path'), '| private:', d.get('private'), '| internal:', d.get('internal'))
"
done
echo "=== 企业仓列表里 website 的可见性 ==="
curl -sS -m 20 "https://gitee.com/api/v5/enterprises/${DST_OWNER}/repos?access_token=${DST_TOKEN}&per_page=100" \
echo "=== 2. 匿名可见性(200=公开,403/404=不可见) ==="
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}" \
-w '删仓 HTTP %{http_code}\n' -o /tmp/del.json || 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}" \
| python3 -c "
import sys, json
try:
d = json.load(sys.stdin)
except Exception:
print('parse fail'); raise SystemExit
if isinstance(d, dict):
print('message:', d.get('message')); raise SystemExit
for r in d:
print(r.get('path'), '| private:', r.get('private'), '| internal:', r.get('internal'))
d = json.load(sys.stdin)
if 'message' in d:
print('message:', d.get('message'))
else:
for k in ('path','private','internal','public','visibility'):
print(k, '=', d.get(k))
"
curl -s -o /dev/null -w "匿名 website: HTTP %{http_code}\n" -m 20 "https://gitee.com/${DST_OWNER}/website"