Merge pull request '***v32' (#32) from mitch into develop
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
commit
00a1d71bf2
@ -27,6 +27,7 @@ steps:
|
||||
- pull_request
|
||||
|
||||
# AI コードレビュー(skip-ai-review ラベル付き PR はスキップ)
|
||||
# 成功時に ai-reviewed ラベルを Gitea API で付与
|
||||
ai-review:
|
||||
image: ghcr.io/slb350/drep:latest
|
||||
environment:
|
||||
@ -70,6 +71,41 @@ steps:
|
||||
|
||||
echo "★ Running drep review for ${CI_REPO} PR #${CI_COMMIT_PULL_REQUEST}"
|
||||
drep review "${CI_REPO}" "${CI_COMMIT_PULL_REQUEST}"
|
||||
|
||||
echo "★ Adding ai-reviewed label to PR #${CI_COMMIT_PULL_REQUEST}"
|
||||
GITEA_API="https://gitea.git.mitchecp.com/api/v1"
|
||||
REPO_API="${GITEA_API}/repos/${CI_REPO_OWNER}/${CI_REPO_NAME}"
|
||||
|
||||
HAS_LABEL=$(curl -fsS \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
"${REPO_API}/issues/${CI_COMMIT_PULL_REQUEST}" \
|
||||
| python3 -c "import json,sys; labels=json.load(sys.stdin).get('labels',[]); print('yes' if any(l.get('name')=='ai-reviewed' for l in labels) else 'no')")
|
||||
|
||||
if [ "$HAS_LABEL" = "yes" ]; then
|
||||
echo "Label ai-reviewed already present on PR #${CI_COMMIT_PULL_REQUEST}"
|
||||
else
|
||||
LABEL_ID=$(curl -fsS \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
"${REPO_API}/labels" \
|
||||
| python3 -c "import json,sys; print(next((l['id'] for l in json.load(sys.stdin) if l.get('name')=='ai-reviewed'), ''))")
|
||||
|
||||
if [ -z "$LABEL_ID" ]; then
|
||||
LABEL_ID=$(curl -fsS -X POST \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"name":"ai-reviewed","color":"0e8a16","description":"Drep AI review completed by Woodpecker"}' \
|
||||
"${REPO_API}/labels" \
|
||||
| python3 -c "import json,sys; print(json.load(sys.stdin)['id'])")
|
||||
fi
|
||||
|
||||
curl -fsS -X POST \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"labels\":[${LABEL_ID}]}" \
|
||||
"${REPO_API}/issues/${CI_COMMIT_PULL_REQUEST}/labels"
|
||||
|
||||
echo "Added ai-reviewed label to PR #${CI_COMMIT_PULL_REQUEST}"
|
||||
fi
|
||||
when:
|
||||
event:
|
||||
- pull_request
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user