Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions .github/workflows/auto-assign-reviewers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ on:
jobs:
assign-reviewers:
runs-on: ubuntu-22.04
if: github.repository_owner == 'RT-Thread'
# if: github.repository_owner == 'RT-Thread'
permissions:
issues: read
pull-requests: write
Expand Down Expand Up @@ -87,7 +87,7 @@ jobs:

# Check if response is valid JSON
if jq -e . >/dev/null 2>&1 <<<"$existing_comment"; then
existing_comment=$(jq -r '.[] | select(.user.login == "github-actions[bot]") | {body: .body} | @base64' <<< "$existing_comment")
existing_comment=$(jq -r '.[] | select(.user.login == "github-actions[bot]" and (.body | contains("<!-- Auto Review Assistant Comment -->"))) | {body: .body} | @base64' <<< "$existing_comment")
else
existing_comment=""
echo "Warning: Invalid JSON response from GitHub API for comments"
Expand Down Expand Up @@ -341,6 +341,7 @@ jobs:
fi
current_time=$(TZ='Asia/Shanghai' date +"%Y-%m-%d %H:%M CST")
{
echo "<!-- Auto Review Assistant Comment -->"
echo "## 📌 Code Review Assignment"
echo ""
for tag in $unique_tags; do
Expand Down Expand Up @@ -399,7 +400,7 @@ jobs:
existing_comment=$(curl -s \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/issues/${{ steps.extract-pr.outputs.PR_NUMBER }}/comments" | \
jq -r '.[] | select(.user.login == "github-actions[bot]") | {id: .id, body: .body} | @base64')
jq -r '.[] | select(.user.login == "github-actions[bot]" and (.body | contains("<!-- Auto Review Assistant Comment -->"))) | {id: .id, body: .body} | @base64')

if [[ -n "$existing_comment" ]]; then
# 更新现有评论
Expand Down Expand Up @@ -428,7 +429,7 @@ jobs:

# Check if response is valid JSON
if jq -e . >/dev/null 2>&1 <<<"$existing_comment"; then
existing_comment=$(jq -r '.[] | select(.user.login == "github-actions[bot]") | {body: .body} | @base64' <<< "$existing_comment")
existing_comment=$(jq -r '.[] | select(.user.login == "github-actions[bot]" and (.body | contains("<!-- Auto Review Assistant Comment -->"))) | {body: .body} | @base64' <<< "$existing_comment")
else
existing_comment=""
echo "Warning: Invalid JSON response from GitHub API"
Expand Down Expand Up @@ -461,4 +462,4 @@ jobs:
path: |
unique_tags_bak.txt
unique_reviewers_bak.txt
key: ${{ runner.os }}-auto-assign-reviewers-${{ steps.extract-pr.outputs.PR_NUMBER }}-${{ steps.get_comment_time.outputs.CACHE_TIMESTAMP }}-${{ github.run_id }}
key: ${{ runner.os }}-auto-assign-reviewers-${{ steps.extract-pr.outputs.PR_NUMBER }}-${{ steps.get_comment_time.outputs.CACHE_TIMESTAMP }}-${{ github.run_id }}
43 changes: 32 additions & 11 deletions .github/workflows/pr_format_bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ permissions:

jobs:
notify-format:
if: github.repository_owner == 'RT-Thread'
# if: github.repository_owner == 'RT-Thread'
runs-on: ubuntu-latest
steps:
- name: Check if first commit and add comment
Expand Down Expand Up @@ -47,6 +47,7 @@ jobs:

# 使用数组存储多行消息
message_lines=(
"<!-- PR Format Notification Comment -->"
"**👋 感谢您对 RT-Thread 的贡献!Thank you for your contribution to RT-Thread!**"
""
"为确保代码符合 RT-Thread 的编码规范,请在你的仓库中执行以下步骤运行代码格式化工作流。"
Expand Down Expand Up @@ -82,26 +83,46 @@ jobs:
echo "Message content:"
echo "$message"

# 查找现有的 bot 评论
existing_comment=$(curl -s \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
"https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments" | \
jq -r '.[] | select(.user.login == "github-actions[bot]" and (.body | contains("<!-- PR Format Notification Comment -->"))) | {id: .id, body: .body} | @base64')

# 使用 jq 安全地构建 JSON 负载
json_payload=$(jq -n --arg body "$message" '{"body": $body}')

# 发送评论到 PR
response=$(curl -s -w "\n%{http_code}" \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
"https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments" \
-d "$json_payload")
if [[ -n "$existing_comment" ]]; then
# 更新现有评论
comment_id=$(echo "$existing_comment" | head -1 | base64 -d | jq -r .id)
echo "Updating existing comment $comment_id"
response=$(curl -s -w "\n%{http_code}" \
-X PATCH \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-d "$json_payload" \
"https://api.github.com/repos/${{ github.repository }}/issues/comments/$comment_id")
else
# 创建新评论
echo "Creating new comment"
response=$(curl -s -w "\n%{http_code}" \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-d "$json_payload" \
"https://api.github.com/repos/${{ github.event.pull_request.number }}/comments")
fi

# 提取 HTTP 状态码和响应体
http_code=$(echo "$response" | tail -n1)
response_body=$(echo "$response" | sed '$d')

if [ "$http_code" -eq 201 ]; then
echo "Format notification comment added successfully"
if [ "$http_code" -eq 201 ] || [ "$http_code" -eq 200 ]; then
echo "Format notification comment added/updated successfully"
echo "Comment URL: $(echo "$response_body" | jq -r '.html_url')"
else
echo "Failed to add comment. HTTP status: $http_code"
echo "Failed to add/update comment. HTTP status: $http_code"
echo "Response: $response_body"
exit 1
fi
Expand Down
1 change: 1 addition & 0 deletions bsp/renesas/ra4e2-ek/.api_xml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ddscApi/>

Loading