chore: 移除一次性探测/清理工作流(Gitee 删除需 projects 权限,API 侧 403)
mirror-to-gitee / mirror (push) Successful in 4s
mirror-to-gitee / mirror (push) Successful in 4s
This commit is contained in:
@@ -1,58 +0,0 @@
|
|||||||
name: cleanup-old-gitee-repos
|
|
||||||
|
|
||||||
# 一次性任务:删除 Gitee 企业仓下 12 个已并入单仓的旧仓。
|
|
||||||
# 结果写入 report.txt 并作为 artifact 上传(Gitea 日志无读取 API,只能靠 artifact 回报)。
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
cleanup:
|
|
||||||
runs-on: host
|
|
||||||
steps:
|
|
||||||
- name: 删除旧仓并生成报告
|
|
||||||
env:
|
|
||||||
DST_TOKEN: ${{ secrets.GITEE_TOKEN }}
|
|
||||||
DST_OWNER: ${{ secrets.GITEE_OWNER }}
|
|
||||||
run: |
|
|
||||||
set -u
|
|
||||||
REPORT="$PWD/report.txt"
|
|
||||||
: > "$REPORT"
|
|
||||||
log() { echo "$@" | tee -a "$REPORT"; }
|
|
||||||
|
|
||||||
REPOS="iotlcm-admin-svr iotlcm-admin-ui iotlcm-app iotlcm-bot iotlcm-deploy iotlcm-docs iotlcm-onelink-mock iotlcm-openapi iotlcm-sms iotlcm-upstream-chan iotlcm-upstream-proxy iotlcm-worker-svr"
|
|
||||||
|
|
||||||
log "=== 1. 删除(DELETE /repos/{owner}/{repo})==="
|
|
||||||
for r in $REPOS; do
|
|
||||||
if [ "$r" = "iotlcm" ]; then log "❌ 拒绝删除单仓"; exit 1; fi
|
|
||||||
code=$(curl -sS -o /tmp/b -w '%{http_code}' -X DELETE \
|
|
||||||
"https://gitee.com/api/v5/repos/${DST_OWNER}/${r}?access_token=${DST_TOKEN}")
|
|
||||||
log "DELETE ${r} -> $code $(head -c 120 /tmp/b)"
|
|
||||||
done
|
|
||||||
|
|
||||||
log ""
|
|
||||||
log "=== 2. 复核(期望 404)==="
|
|
||||||
for r in $REPOS; do
|
|
||||||
code=$(curl -sS -o /tmp/b -w '%{http_code}' \
|
|
||||||
"https://gitee.com/api/v5/repos/${DST_OWNER}/${r}?access_token=${DST_TOKEN}")
|
|
||||||
log "GET ${r} -> $code"
|
|
||||||
done
|
|
||||||
|
|
||||||
log ""
|
|
||||||
log "=== 3. 单仓仍须 200 ==="
|
|
||||||
code=$(curl -sS -o /tmp/b -w '%{http_code}' \
|
|
||||||
"https://gitee.com/api/v5/repos/${DST_OWNER}/iotlcm?access_token=${DST_TOKEN}")
|
|
||||||
log "GET iotlcm -> $code $(head -c 160 /tmp/b)"
|
|
||||||
|
|
||||||
log ""
|
|
||||||
log "=== 4. 企业仓列表(前 2000 字符)==="
|
|
||||||
curl -sS "https://gitee.com/api/v5/enterprises/${DST_OWNER}/repos?access_token=${DST_TOKEN}&per_page=100" \
|
|
||||||
| head -c 2000 | tee -a "$REPORT"
|
|
||||||
log ""
|
|
||||||
log "=== done ==="
|
|
||||||
|
|
||||||
- name: 上传报告
|
|
||||||
if: always()
|
|
||||||
uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: cleanup-report
|
|
||||||
path: report.txt
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
name: probe-gitee-delete
|
|
||||||
|
|
||||||
# 一次性探测:找出 Gitee 侧删除仓库的正确端点/权限。
|
|
||||||
# 只对 iotlcm-sms 做探测,不实际删其它仓。
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
probe:
|
|
||||||
runs-on: host
|
|
||||||
steps:
|
|
||||||
- name: 探测
|
|
||||||
env:
|
|
||||||
DST_TOKEN: ${{ secrets.GITEE_TOKEN }}
|
|
||||||
DST_OWNER: ${{ secrets.GITEE_OWNER }}
|
|
||||||
DST_USER: ${{ secrets.GITEE_USER }}
|
|
||||||
run: |
|
|
||||||
set -u
|
|
||||||
T="$DST_TOKEN"; O="$DST_OWNER"; R="iotlcm-sms"
|
|
||||||
t() { # 标签 方法 URL [data]
|
|
||||||
local label="$1" method="$2" url="$3" data="${4:-}"
|
|
||||||
if [ -n "$data" ]; then
|
|
||||||
code=$(curl -sS -o /tmp/b -w '%{http_code}' -X "$method" -H 'Content-Type: application/json' -d "$data" "$url")
|
|
||||||
else
|
|
||||||
code=$(curl -sS -o /tmp/b -w '%{http_code}' -X "$method" "$url")
|
|
||||||
fi
|
|
||||||
echo "[$label] $method $url -> $code $(head -c 200 /tmp/b)"
|
|
||||||
}
|
|
||||||
|
|
||||||
echo "=== 令牌身份 / 权限 ==="
|
|
||||||
curl -sS "https://gitee.com/api/v5/user?access_token=$T" | head -c 400; echo
|
|
||||||
curl -sS "https://gitee.com/api/v5/enterprises/$O?access_token=$T" | head -c 400; echo
|
|
||||||
echo "--- 目标仓权限(permission 字段)---"
|
|
||||||
curl -sS "https://gitee.com/api/v5/repos/$O/$R?access_token=$T" \
|
|
||||||
| python3 -c "import json,sys;d=json.load(sys.stdin);print({k:d.get(k) for k in ('full_name','permission','private','owner','namespace')})" 2>/dev/null
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
echo "=== 端点变体 ==="
|
|
||||||
t A DELETE "https://gitee.com/api/v5/repos/$O/$R?access_token=$T"
|
|
||||||
t B DELETE "https://gitee.com/api/v5/enterprises/$O/repos/$R?access_token=$T"
|
|
||||||
t C DELETE "https://gitee.com/api/v5/enterprises/$O/repos/$R?access_token=$T&path=$R"
|
|
||||||
t D POST "https://gitee.com/api/v5/enterprises/$O/repos/$R/archive?access_token=$T"
|
|
||||||
t E DELETE "https://gitee.com/api/v5/repos/$O/$R" "access_token=$T"
|
|
||||||
echo ""
|
|
||||||
echo "=== 探测后该仓是否还在 ==="
|
|
||||||
curl -sS -o /dev/null -w 'GET %{http_code}\n' "https://gitee.com/api/v5/repos/$O/$R?access_token=$T"
|
|
||||||
Reference in New Issue
Block a user