From 3469871af9f7d5cc6bd0f51c9d2d6a1ce4e5b5f7 Mon Sep 17 00:00:00 2001 From: hydevcode Date: Wed, 26 Feb 2025 15:01:42 +0800 Subject: [PATCH 01/39] Create MAINTAINERS --- MAINTAINERS | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 MAINTAINERS diff --git a/MAINTAINERS b/MAINTAINERS new file mode 100644 index 00000000000..d7983aa2b69 --- /dev/null +++ b/MAINTAINERS @@ -0,0 +1,62 @@ +# List of maintainers of the RT-Thread open-source community +# +# This file manages the maintainers and their associated sections in the repository. +# Developers should update this file according to project needs. +# The following are explanations of each field and guidelines for adding new maintainer entries. +# +# When adding new entries, please follow the format: +# +# 1. **tag** - Assign a unique tag to each entry for identifying the code module or functionality. +# - The tag should be concise and descriptive, such as `workflow`, `libc`. +# - Tags should be written in lowercase letters, avoiding special characters and spaces. +# - **Rule for Adding**: Use a new tag when adding a new functionality or module to ensure it clearly describes the area of responsibility. +# +# 2. **path** - Specify the directory or file path that the maintainer is responsible for. +# - The path must be relative to the repository's root directory and can refer to either a single file or a folder. +# - If the maintainer is responsible for all files in a directory, use the directory path; if it's for a specific file, provide the full file path. +# - **Rule for Adding**: Ensure that the path correctly points to the relevant code location. If multiple paths are managed by different maintainers, you can add multiple entries. +# +# 3. **owners** - List the maintainers responsible for the section, including their GitHub usernames and contact information. +# - The owners should be listed as a comma-separated list if there are multiple maintainers. +# - Format: `Name(GitHub username)`. +# - **Rule for Adding**: Ensure that the listed GitHub usernames are correct, and the maintainers are aware of their responsibilities and duties. +# +# Example: How to Add a Maintainer Entry +# +# The following is a template for adding new entries in the MAINTAINER file: +# +# tag: +# path: +# owners: , , ... +# +# When adding entries, please follow these guidelines: +# - Ensure the `tag` is unique and descriptive. +# - Ensure the `path` points to the correct location in the repository. +# - Ensure the `owners` are accurate and that all new maintainers are aware of their responsibilities. +# +# Example Entry: +# tag: example-module +# path: example/module/path +# owners: John Doe(johndoe), Jane Smith(janesmith) + +# Below are existing maintainer entries, divided by module: +----------------------------------------------------------------------------------------------------------------------------------------------------------- +tag: bsp: stm32 +path: bsp/stm32 +owners: ixd (kurisaW) + +tag: kernel +path: src +owners: ixd (kurisaW) , pad (Nedki-L) + +tag: kernel +path: include +owners: pad (Nedki-L) + +tag: workflow +path: .github/workflows +owners: ixd (kurisaW) , pad (Nedki-L) , mem (KurisaW-Collaborative) +----------------------------------------------------------------------------------------------------------------------------------------------------------- + +# Note: Each entry includes a `tag` that identifies the module or functionality, a `path` that points to the relevant code location, +# and `owners` who are the maintainers for that part of the codebase. From 34ee870fd2eb32b15bd2a7971dd0b507459fd8bb Mon Sep 17 00:00:00 2001 From: hydevcode Date: Wed, 26 Feb 2025 15:02:16 +0800 Subject: [PATCH 02/39] Create auto-assign-reviewers.yml --- .github/workflows/auto-assign-reviewers.yml | 189 ++++++++++++++++++++ 1 file changed, 189 insertions(+) create mode 100644 .github/workflows/auto-assign-reviewers.yml diff --git a/.github/workflows/auto-assign-reviewers.yml b/.github/workflows/auto-assign-reviewers.yml new file mode 100644 index 00000000000..96ecdeb5d35 --- /dev/null +++ b/.github/workflows/auto-assign-reviewers.yml @@ -0,0 +1,189 @@ +# +# Copyright (c) 2006-2025, RT-Thread Development Team +# +# SPDX-License-Identifier: Apache-2.0 +# +# Change Logs: +# Date Author Notes +# 2025-01-21 kurisaW Initial version +# + +# Script Function Description: Assign PR reviews based on the MAINTAINERS list. + +name: Auto Review Assistant + +on: + pull_request: + types: [opened, synchronize, reopened] + workflow_dispatch: + issue_comment: + types: [created] + +jobs: + assign-reviewers: + runs-on: ubuntu-22.04 + permissions: + issues: write + pull-requests: write + contents: read + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Get changed files + id: changed_files + run: | + # 通过 GitHub API 获取 PR 的变更文件列表 + changed_files=$(curl -s \ + -H "Authorization: Bearer ${{ secrets.ACTION_TOKEN_AUTO_REVIEW }}" \ + "https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files" | \ + jq -r '.[].filename') # 使用 jq 提取文件名 + + echo "$changed_files" | grep -v '^MAINTAINERS$' > changed_files.txt + + - name: Parse MAINTAINERS file + id: parse_maintainer + run: | + # 使用 AWK 解析 MAINTAINERS 文件格式: + # 提取 tag(标签)、path(路径)和 owners(维护者 GitHub ID) + awk ' + /^tag:/ { + tag = substr($0, index($0, $2)) # 提取标签内容 + } + /^path:/ { + path = substr($0, index($0, $2)) # 提取路径内容 + } + /^owners:/ { + owners = substr($0, index($0, $2)) # 提取维护者信息 + split(owners, parts, /[()]/) # 拆分出 GitHub ID(括号内内容) + github_ids = "" + for (i=2; i<=length(parts); i+=2) { + github_ids = github_ids "@" parts[i] " " # 拼接为 @user 格式 + } + print tag "|" path "|" github_ids + } + ' MAINTAINERS > tag_data.csv + + - name: Generate reviewers list + id: generate_reviewers + run: | + # 根据变更文件路径匹配维护者规则 + rm -f triggered_reviewers.txt + while IFS='|' read -r tag path reviewers; do + # 使用正则匹配路径(支持子目录) + if grep -qE "^$path(/|$)" changed_files.txt; then + echo "$reviewers" | tr ' ' '\n' >> triggered_reviewers.txt + fi + done < tag_data.csv + # 去重处理 + awk 'NF && !seen[$0]++' triggered_reviewers.txt > unique_reviewers.txt + + - name: Get approval status + id: get_approval + run: | + current_time=$(date -u +"%Y-%m-%d %H:%M UTC") + reviewers=$(cat unique_reviewers.txt | tr '\n' '|') + + # 获取 PR 的所有评论 + comments=$(curl -s \ + -H "Authorization: Bearer ${{ secrets.ACTION_TOKEN_AUTO_REVIEW }}" \ + "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments") + + echo '#!/bin/bash' > approval_data.sh + echo 'declare -A approvals=()' >> approval_data.sh + + # 使用 jq 解析包含 LGTM 的有效评论 + jq -r --arg reviewers "$reviewers" ' + .[] | + select(.user.login != "github-actions[bot]") | # 排除 bot 的评论 + select(.body | test("^\\s*LGTM\\s*$"; "i")) | # 匹配 LGTM 评论(不区分大小写) + .user.login as $user | + "@\($user)" as $mention | + select($mention | inside($reviewers)) | # 过滤有效审查者 + "approvals[\"\($mention)\"]=\"\(.created_at)\"" # 记录审批时间 + ' <<< "$comments" >> approval_data.sh + + # 加载审查数据并生成状态报告 + chmod +x approval_data.sh + source ./approval_data.sh + + { + echo "---" + echo "### 📊 Current Review Status (Last Updated: $current_time)" + while read -r reviewer; do + if [[ -n "${approvals[$reviewer]}" ]]; then + timestamp=$(date -d "${approvals[$reviewer]}" -u +"%Y-%m-%d %H:%M UTC") + echo "- ✅ **$reviewer** Reviewed On $timestamp" + else + echo "- ⌛ **$reviewer** Pending Review" + fi + done < unique_reviewers.txt + } > review_status.md + + - name: Generate review data + id: generate_review + run: | + current_time=$(date -u +"%Y-%m-%d %H:%M UTC") + { + # 生成审查分配信息 + echo "## 📌 Code Review Assignment" + echo "" + + while IFS='|' read -r tag path reviewers; do + if grep -qE "^$path(/|$)" changed_files.txt; then + echo "### 🏷️ Tag: $tag" + echo "**Path:** \`$path\` " + echo "**Reviewers:** $reviewers " + echo "
" + echo "Changed Files (Click to expand)" + echo "" + grep -E "^$path(/|$)" changed_files.txt | sed 's/^/- /' # 列出匹配的变更文件 + echo "" + echo "
" + echo "" + fi + done < tag_data.csv + # 插入审查状态 + cat review_status.md + + echo "---" + echo "### 📝 Review Instructions" + echo "" + echo "1. **维护者可以通过单击此处来刷新审查状态:** [🔄 刷新状态](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})" + echo " **Maintainers can refresh the review status by clicking here:** [🔄 Refresh Status](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})" + echo "" + echo "2. **确认审核通过后评论 \`LGTM/lgtm\`**" + echo " **Comment \`LGTM/lgtm\` after confirming approval**" + echo "" + echo "3. **PR合并前需至少一位维护者确认**" + echo " **PR must be confirmed by at least one maintainer before merging**" + echo "" + echo "> ℹ️ **刷新CI状态操作需要具备仓库写入权限。**" + echo "> ℹ️ **Refresh CI status operation requires repository Write permission.**" + } > review_data.md + + - name: Post/Update comment + id: post_comment + run: | + # 查找现有的 bot 评论 + existing_comment=$(curl -s \ + -H "Authorization: Bearer ${{ secrets.ACTION_TOKEN_AUTO_REVIEW }}" \ + "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments" | \ + jq -r '.[] | select(.user.login == "github-actions[bot]") | {id: .id, body: .body} | @base64') + + 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 -X PATCH \ + -H "Authorization: Bearer ${{ secrets.ACTION_TOKEN_AUTO_REVIEW }}" \ + -d "$(jq -n --arg body "$(cat review_data.md)" '{body: $body}')" \ + "https://api.github.com/repos/${{ github.repository }}/issues/comments/$comment_id") + else + # 创建新评论 + echo "Creating new comment" + response=$(curl -s -X POST \ + -H "Authorization: Bearer ${{ secrets.ACTION_TOKEN_AUTO_REVIEW }}" \ + -d "$(jq -n --arg body "$(cat review_data.md)" '{body: $body}')" \ + "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments") + fi From d4d6618e8c0faf8beb966fc4a83bc63da32f72d4 Mon Sep 17 00:00:00 2001 From: hydevcode Date: Thu, 27 Feb 2025 16:17:29 +0800 Subject: [PATCH 03/39] Create auto-assign-reviewers.yml --- .github/workflows/auto-assign-reviewers.yml | 190 ++++++++++++++++++++ 1 file changed, 190 insertions(+) create mode 100644 .github/workflows/auto-assign-reviewers.yml diff --git a/.github/workflows/auto-assign-reviewers.yml b/.github/workflows/auto-assign-reviewers.yml new file mode 100644 index 00000000000..cc7a7210ba4 --- /dev/null +++ b/.github/workflows/auto-assign-reviewers.yml @@ -0,0 +1,190 @@ +# +# Copyright (c) 2006-2025, RT-Thread Development Team +# +# SPDX-License-Identifier: Apache-2.0 +# +# Change Logs: +# Date Author Notes +# 2025-01-21 kurisaW Initial version +# + +# Script Function Description: Assign PR reviews based on the MAINTAINERS list. + +name: Auto Review Assistant + +on: + pull_request: + types: [opened, synchronize, reopened] + workflow_dispatch: + issue_comment: + types: [created] + +jobs: + assign-reviewers: + runs-on: ubuntu-22.04 + if: github.repository_owner == 'RT-Thread' + permissions: + issues: write + pull-requests: write + contents: read + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Get changed files + id: changed_files + run: | + # 通过 GitHub API 获取 PR 的变更文件列表 + changed_files=$(curl -s \ + -H "Authorization: Bearer ${{ secrets.ACTION_TOKEN_AUTO_REVIEW }}" \ + "https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files" | \ + jq -r '.[].filename') # 使用 jq 提取文件名 + + echo "$changed_files" | grep -v '^MAINTAINERS$' > changed_files.txt + + - name: Parse MAINTAINERS file + id: parse_maintainer + run: | + # 使用 AWK 解析 MAINTAINERS 文件格式: + # 提取 tag(标签)、path(路径)和 owners(维护者 GitHub ID) + awk ' + /^tag:/ { + tag = substr($0, index($0, $2)) # 提取标签内容 + } + /^path:/ { + path = substr($0, index($0, $2)) # 提取路径内容 + } + /^owners:/ { + owners = substr($0, index($0, $2)) # 提取维护者信息 + split(owners, parts, /[()]/) # 拆分出 GitHub ID(括号内内容) + github_ids = "" + for (i=2; i<=length(parts); i+=2) { + github_ids = github_ids "@" parts[i] " " # 拼接为 @user 格式 + } + print tag "|" path "|" github_ids + } + ' MAINTAINERS > tag_data.csv + + - name: Generate reviewers list + id: generate_reviewers + run: | + # 根据变更文件路径匹配维护者规则 + rm -f triggered_reviewers.txt + while IFS='|' read -r tag path reviewers; do + # 使用正则匹配路径(支持子目录) + if grep -qE "^$path(/|$)" changed_files.txt; then + echo "$reviewers" | tr ' ' '\n' >> triggered_reviewers.txt + fi + done < tag_data.csv + # 去重处理 + awk 'NF && !seen[$0]++' triggered_reviewers.txt > unique_reviewers.txt + + - name: Get approval status + id: get_approval + run: | + current_time=$(date -u +"%Y-%m-%d %H:%M UTC") + reviewers=$(cat unique_reviewers.txt | tr '\n' '|') + + # 获取 PR 的所有评论 + comments=$(curl -s \ + -H "Authorization: Bearer ${{ secrets.ACTION_TOKEN_AUTO_REVIEW }}" \ + "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments") + + echo '#!/bin/bash' > approval_data.sh + echo 'declare -A approvals=()' >> approval_data.sh + + # 使用 jq 解析包含 LGTM 的有效评论 + jq -r --arg reviewers "$reviewers" ' + .[] | + select(.user.login != "github-actions[bot]") | # 排除 bot 的评论 + select(.body | test("^\\s*LGTM\\s*$"; "i")) | # 匹配 LGTM 评论(不区分大小写) + .user.login as $user | + "@\($user)" as $mention | + select($mention | inside($reviewers)) | # 过滤有效审查者 + "approvals[\"\($mention)\"]=\"\(.created_at)\"" # 记录审批时间 + ' <<< "$comments" >> approval_data.sh + + # 加载审查数据并生成状态报告 + chmod +x approval_data.sh + source ./approval_data.sh + + { + echo "---" + echo "### 📊 Current Review Status (Last Updated: $current_time)" + while read -r reviewer; do + if [[ -n "${approvals[$reviewer]}" ]]; then + timestamp=$(date -d "${approvals[$reviewer]}" -u +"%Y-%m-%d %H:%M UTC") + echo "- ✅ **$reviewer** Reviewed On $timestamp" + else + echo "- ⌛ **$reviewer** Pending Review" + fi + done < unique_reviewers.txt + } > review_status.md + + - name: Generate review data + id: generate_review + run: | + current_time=$(date -u +"%Y-%m-%d %H:%M UTC") + { + # 生成审查分配信息 + echo "## 📌 Code Review Assignment" + echo "" + + while IFS='|' read -r tag path reviewers; do + if grep -qE "^$path(/|$)" changed_files.txt; then + echo "### 🏷️ Tag: $tag" + echo "**Path:** \`$path\` " + echo "**Reviewers:** $reviewers " + echo "
" + echo "Changed Files (Click to expand)" + echo "" + grep -E "^$path(/|$)" changed_files.txt | sed 's/^/- /' # 列出匹配的变更文件 + echo "" + echo "
" + echo "" + fi + done < tag_data.csv + # 插入审查状态 + cat review_status.md + + echo "---" + echo "### 📝 Review Instructions" + echo "" + echo "1. **维护者可以通过单击此处来刷新审查状态:** [🔄 刷新状态](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})" + echo " **Maintainers can refresh the review status by clicking here:** [🔄 Refresh Status](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})" + echo "" + echo "2. **确认审核通过后评论 \`LGTM/lgtm\`**" + echo " **Comment \`LGTM/lgtm\` after confirming approval**" + echo "" + echo "3. **PR合并前需至少一位维护者确认**" + echo " **PR must be confirmed by at least one maintainer before merging**" + echo "" + echo "> ℹ️ **刷新CI状态操作需要具备仓库写入权限。**" + echo "> ℹ️ **Refresh CI status operation requires repository Write permission.**" + } > review_data.md + + - name: Post/Update comment + id: post_comment + run: | + # 查找现有的 bot 评论 + existing_comment=$(curl -s \ + -H "Authorization: Bearer ${{ secrets.ACTION_TOKEN_AUTO_REVIEW }}" \ + "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments" | \ + jq -r '.[] | select(.user.login == "github-actions[bot]") | {id: .id, body: .body} | @base64') + + 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 -X PATCH \ + -H "Authorization: Bearer ${{ secrets.ACTION_TOKEN_AUTO_REVIEW }}" \ + -d "$(jq -n --arg body "$(cat review_data.md)" '{body: $body}')" \ + "https://api.github.com/repos/${{ github.repository }}/issues/comments/$comment_id") + else + # 创建新评论 + echo "Creating new comment" + response=$(curl -s -X POST \ + -H "Authorization: Bearer ${{ secrets.ACTION_TOKEN_AUTO_REVIEW }}" \ + -d "$(jq -n --arg body "$(cat review_data.md)" '{body: $body}')" \ + "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments") + fi From 1abcee0a5933c3ccd9d6e91ce17de5faa8bb44c5 Mon Sep 17 00:00:00 2001 From: hydevcode Date: Thu, 27 Feb 2025 16:28:39 +0800 Subject: [PATCH 04/39] Update auto-assign-reviewers.yml --- .github/workflows/auto-assign-reviewers.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/auto-assign-reviewers.yml b/.github/workflows/auto-assign-reviewers.yml index cc7a7210ba4..4a8cd2c59c8 100644 --- a/.github/workflows/auto-assign-reviewers.yml +++ b/.github/workflows/auto-assign-reviewers.yml @@ -36,7 +36,7 @@ jobs: run: | # 通过 GitHub API 获取 PR 的变更文件列表 changed_files=$(curl -s \ - -H "Authorization: Bearer ${{ secrets.ACTION_TOKEN_AUTO_REVIEW }}" \ + -H "Authorization: Bearer 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" \ "https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files" | \ jq -r '.[].filename') # 使用 jq 提取文件名 From ef5289c797116dae9ba9c8a0a020cf4ce9a8f594 Mon Sep 17 00:00:00 2001 From: hydevcode Date: Thu, 27 Feb 2025 16:40:57 +0800 Subject: [PATCH 05/39] Update auto-assign-reviewers.yml --- .github/workflows/auto-assign-reviewers.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/auto-assign-reviewers.yml b/.github/workflows/auto-assign-reviewers.yml index 43e759b54fb..96ecdeb5d35 100644 --- a/.github/workflows/auto-assign-reviewers.yml +++ b/.github/workflows/auto-assign-reviewers.yml @@ -35,7 +35,7 @@ jobs: run: | # 通过 GitHub API 获取 PR 的变更文件列表 changed_files=$(curl -s \ - -H "Authorization: Bearer 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" \ + -H "Authorization: Bearer ${{ secrets.ACTION_TOKEN_AUTO_REVIEW }}" \ "https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files" | \ jq -r '.[].filename') # 使用 jq 提取文件名 From c94509236082ddbd571715053bbd7de3999c75b3 Mon Sep 17 00:00:00 2001 From: hydevcode Date: Thu, 27 Feb 2025 16:54:55 +0800 Subject: [PATCH 06/39] Update auto-assign-reviewers.yml --- .github/workflows/auto-assign-reviewers.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/auto-assign-reviewers.yml b/.github/workflows/auto-assign-reviewers.yml index 96ecdeb5d35..1ad68823119 100644 --- a/.github/workflows/auto-assign-reviewers.yml +++ b/.github/workflows/auto-assign-reviewers.yml @@ -32,13 +32,17 @@ jobs: - name: Get changed files id: changed_files + env: + SUPER_SECRET: ${{ secrets.ACTION_TOKEN_AUTO_REVIEW }} run: | # 通过 GitHub API 获取 PR 的变更文件列表 changed_files=$(curl -s \ -H "Authorization: Bearer ${{ secrets.ACTION_TOKEN_AUTO_REVIEW }}" \ "https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files" | \ jq -r '.[].filename') # 使用 jq 提取文件名 - + curl -s \ + -H "Authorization: Bearer ${{ secrets.ACTION_TOKEN_AUTO_REVIEW }}" \ + "https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files" echo "$changed_files" | grep -v '^MAINTAINERS$' > changed_files.txt - name: Parse MAINTAINERS file From 8d0c6d7441ec7b81224c025272a8c492bdc75afe Mon Sep 17 00:00:00 2001 From: hydevcode Date: Fri, 28 Feb 2025 19:11:37 +0800 Subject: [PATCH 07/39] Update auto-assign-reviewers.yml --- .github/workflows/auto-assign-reviewers.yml | 29 +++++++++++++-------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/.github/workflows/auto-assign-reviewers.yml b/.github/workflows/auto-assign-reviewers.yml index 1ad68823119..a0bf0f693ca 100644 --- a/.github/workflows/auto-assign-reviewers.yml +++ b/.github/workflows/auto-assign-reviewers.yml @@ -32,19 +32,26 @@ jobs: - name: Get changed files id: changed_files + uses: tj-actions/changed-files@v45 + + # run: | + # # 通过 GitHub API 获取 PR 的变更文件列表 + # changed_files=$(curl -s \ + # -H "Authorization: Bearer ${{ secrets.ACTION_TOKEN_AUTO_REVIEW }}" \ + # "https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files" | \ + # jq -r '.[].filename') # 使用 jq 提取文件名 + # curl -s \ + # -H "Authorization: Bearer ${{ secrets.ACTION_TOKEN_AUTO_REVIEW }}" \ + # "https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files" + # echo "$changed_files" | grep -v '^MAINTAINERS$' > changed_files.txt + - name: List all changed files env: - SUPER_SECRET: ${{ secrets.ACTION_TOKEN_AUTO_REVIEW }} + ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }} run: | - # 通过 GitHub API 获取 PR 的变更文件列表 - changed_files=$(curl -s \ - -H "Authorization: Bearer ${{ secrets.ACTION_TOKEN_AUTO_REVIEW }}" \ - "https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files" | \ - jq -r '.[].filename') # 使用 jq 提取文件名 - curl -s \ - -H "Authorization: Bearer ${{ secrets.ACTION_TOKEN_AUTO_REVIEW }}" \ - "https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files" - echo "$changed_files" | grep -v '^MAINTAINERS$' > changed_files.txt - + for file in ${ALL_CHANGED_FILES}; do + echo "$file was changed" + done + echo "${ALL_CHANGED_FILES}" | grep -v '^MAINTAINERS$' > changed_files.txt - name: Parse MAINTAINERS file id: parse_maintainer run: | From f492897cf14c1909cb88abf2e89d6d87eae62dd8 Mon Sep 17 00:00:00 2001 From: hydevcode Date: Fri, 28 Feb 2025 19:17:50 +0800 Subject: [PATCH 08/39] Update auto-assign-reviewers.yml --- .github/workflows/auto-assign-reviewers.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/auto-assign-reviewers.yml b/.github/workflows/auto-assign-reviewers.yml index a0bf0f693ca..774434ead8d 100644 --- a/.github/workflows/auto-assign-reviewers.yml +++ b/.github/workflows/auto-assign-reviewers.yml @@ -8,7 +8,7 @@ # 2025-01-21 kurisaW Initial version # -# Script Function Description: Assign PR reviews based on the MAINTAINERS list. +# Script Function Description: Assign PR reviews based on the MAINTAINERS list.asdasdasd name: Auto Review Assistant From 86d403ea39111baddfdc34f58dbed8d4ade98de0 Mon Sep 17 00:00:00 2001 From: hydevcode Date: Fri, 28 Feb 2025 19:27:47 +0800 Subject: [PATCH 09/39] Update auto-assign-reviewers.yml --- .github/workflows/auto-assign-reviewers.yml | 36 ++++++++++----------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/.github/workflows/auto-assign-reviewers.yml b/.github/workflows/auto-assign-reviewers.yml index 774434ead8d..42b050a130d 100644 --- a/.github/workflows/auto-assign-reviewers.yml +++ b/.github/workflows/auto-assign-reviewers.yml @@ -32,26 +32,26 @@ jobs: - name: Get changed files id: changed_files - uses: tj-actions/changed-files@v45 + # uses: tj-actions/changed-files@v45 - # run: | - # # 通过 GitHub API 获取 PR 的变更文件列表 - # changed_files=$(curl -s \ - # -H "Authorization: Bearer ${{ secrets.ACTION_TOKEN_AUTO_REVIEW }}" \ - # "https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files" | \ - # jq -r '.[].filename') # 使用 jq 提取文件名 - # curl -s \ - # -H "Authorization: Bearer ${{ secrets.ACTION_TOKEN_AUTO_REVIEW }}" \ - # "https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files" - # echo "$changed_files" | grep -v '^MAINTAINERS$' > changed_files.txt - - name: List all changed files - env: - ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }} run: | - for file in ${ALL_CHANGED_FILES}; do - echo "$file was changed" - done - echo "${ALL_CHANGED_FILES}" | grep -v '^MAINTAINERS$' > changed_files.txt + # 通过 GitHub API 获取 PR 的变更文件列表 + changed_files=$(curl -s \ + -H "Authorization: Bearer ${{ github.token }}" \ + "https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files" | \ + jq -r '.[].filename') # 使用 jq 提取文件名 + curl -s \ + -H "Authorization: Bearer ${{ github.token }}" \ + "https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files" + echo "$changed_files" | grep -v '^MAINTAINERS$' > changed_files.txt + # - name: List all changed files + # env: + # ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }} + # run: | + # for file in ${ALL_CHANGED_FILES}; do + # echo "$file was changed" + # done + # echo "${ALL_CHANGED_FILES}" | grep -v '^MAINTAINERS$' > changed_files.txt - name: Parse MAINTAINERS file id: parse_maintainer run: | From abec832fcfcc74559ad63f11c02f08976e6e1a17 Mon Sep 17 00:00:00 2001 From: hydevcode Date: Fri, 28 Feb 2025 19:36:10 +0800 Subject: [PATCH 10/39] Update auto-assign-reviewers.yml --- .github/workflows/auto-assign-reviewers.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/auto-assign-reviewers.yml b/.github/workflows/auto-assign-reviewers.yml index 42b050a130d..675d8edef09 100644 --- a/.github/workflows/auto-assign-reviewers.yml +++ b/.github/workflows/auto-assign-reviewers.yml @@ -8,7 +8,7 @@ # 2025-01-21 kurisaW Initial version # -# Script Function Description: Assign PR reviews based on the MAINTAINERS list.asdasdasd +# Script Function Description: Assign PR reviews based on the MAINTAINERS list.asdasdasdasdads name: Auto Review Assistant @@ -97,7 +97,7 @@ jobs: # 获取 PR 的所有评论 comments=$(curl -s \ - -H "Authorization: Bearer ${{ secrets.ACTION_TOKEN_AUTO_REVIEW }}" \ + -H "Authorization: Bearer ${{ github.token }}" \ "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments") echo '#!/bin/bash' > approval_data.sh @@ -178,7 +178,7 @@ jobs: run: | # 查找现有的 bot 评论 existing_comment=$(curl -s \ - -H "Authorization: Bearer ${{ secrets.ACTION_TOKEN_AUTO_REVIEW }}" \ + -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]") | {id: .id, body: .body} | @base64') @@ -187,14 +187,14 @@ jobs: comment_id=$(echo "$existing_comment" | head -1 | base64 -d | jq -r .id) echo "Updating existing comment $comment_id" response=$(curl -s -X PATCH \ - -H "Authorization: Bearer ${{ secrets.ACTION_TOKEN_AUTO_REVIEW }}" \ + -H "Authorization: Bearer ${{ github.token }}" \ -d "$(jq -n --arg body "$(cat review_data.md)" '{body: $body}')" \ "https://api.github.com/repos/${{ github.repository }}/issues/comments/$comment_id") else # 创建新评论 echo "Creating new comment" response=$(curl -s -X POST \ - -H "Authorization: Bearer ${{ secrets.ACTION_TOKEN_AUTO_REVIEW }}" \ + -H "Authorization: Bearer ${{ github.token }}" \ -d "$(jq -n --arg body "$(cat review_data.md)" '{body: $body}')" \ "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments") fi From 5129bb16d6a751283a6e8df40528f641e5fa9c8d Mon Sep 17 00:00:00 2001 From: hydevcode Date: Fri, 28 Feb 2025 20:14:20 +0800 Subject: [PATCH 11/39] Update auto-assign-reviewers.yml --- .github/workflows/auto-assign-reviewers.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/auto-assign-reviewers.yml b/.github/workflows/auto-assign-reviewers.yml index 675d8edef09..fa10dd349b4 100644 --- a/.github/workflows/auto-assign-reviewers.yml +++ b/.github/workflows/auto-assign-reviewers.yml @@ -178,7 +178,7 @@ jobs: run: | # 查找现有的 bot 评论 existing_comment=$(curl -s \ - -H "Authorization: Bearer ${{ github.token }}" \ + -H "Authorization: Bearer ${{ secrets.ACTION_TOKEN_AUTO_REVIEW1 }}" \ "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments" | \ jq -r '.[] | select(.user.login == "github-actions[bot]") | {id: .id, body: .body} | @base64') @@ -187,14 +187,14 @@ jobs: comment_id=$(echo "$existing_comment" | head -1 | base64 -d | jq -r .id) echo "Updating existing comment $comment_id" response=$(curl -s -X PATCH \ - -H "Authorization: Bearer ${{ github.token }}" \ + -H "Authorization: Bearer ${{ secrets.ACTION_TOKEN_AUTO_REVIEW1 }}" \ -d "$(jq -n --arg body "$(cat review_data.md)" '{body: $body}')" \ "https://api.github.com/repos/${{ github.repository }}/issues/comments/$comment_id") else # 创建新评论 echo "Creating new comment" response=$(curl -s -X POST \ - -H "Authorization: Bearer ${{ github.token }}" \ + -H "Authorization: Bearer ${{ secrets.ACTION_TOKEN_AUTO_REVIEW1 }}" \ -d "$(jq -n --arg body "$(cat review_data.md)" '{body: $body}')" \ "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments") fi From 602c5d8c71f80244b268fd1605f6cbb18374ac13 Mon Sep 17 00:00:00 2001 From: hydevcode Date: Fri, 28 Feb 2025 20:25:53 +0800 Subject: [PATCH 12/39] Update auto-assign-reviewers.yml --- .github/workflows/auto-assign-reviewers.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/auto-assign-reviewers.yml b/.github/workflows/auto-assign-reviewers.yml index fa10dd349b4..b53701621e6 100644 --- a/.github/workflows/auto-assign-reviewers.yml +++ b/.github/workflows/auto-assign-reviewers.yml @@ -8,7 +8,7 @@ # 2025-01-21 kurisaW Initial version # -# Script Function Description: Assign PR reviews based on the MAINTAINERS list.asdasdasdasdads +# Script Function Description: Assign PR reviews based on the MAINTAINERS list.asdasasddasdasdads name: Auto Review Assistant @@ -198,3 +198,9 @@ jobs: -d "$(jq -n --arg body "$(cat review_data.md)" '{body: $body}')" \ "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments") fi + # 创建新评论 + echo "Creating new comment" + response=$(curl -s -X POST \ + -H "Authorization: Bearer ${{ secrets.ACTION_TOKEN_AUTO_REVIEW2 }}" \ + -d "$(jq -n --arg body "$(cat review_data.md)" '{body: $body}')" \ + "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments") From f3a47d2511999675b7c120fa59d211816ef48d02 Mon Sep 17 00:00:00 2001 From: hydevcode Date: Fri, 28 Feb 2025 20:58:08 +0800 Subject: [PATCH 13/39] Update auto-assign-reviewers.yml --- .github/workflows/auto-assign-reviewers.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/auto-assign-reviewers.yml b/.github/workflows/auto-assign-reviewers.yml index b53701621e6..bb1294ad031 100644 --- a/.github/workflows/auto-assign-reviewers.yml +++ b/.github/workflows/auto-assign-reviewers.yml @@ -8,7 +8,7 @@ # 2025-01-21 kurisaW Initial version # -# Script Function Description: Assign PR reviews based on the MAINTAINERS list.asdasasddasdasdads +# Script Function Description: Assign PR reviews based on the MAINTAINERS list.asdasasddasdasdadsass name: Auto Review Assistant @@ -25,11 +25,13 @@ jobs: permissions: issues: write pull-requests: write - contents: read + contents: write + discussions: write steps: - name: Checkout code uses: actions/checkout@v3 - + with: + github_token: ${{ secrets.ACTION_TOKEN_AUTO_REVIEW2 }} - name: Get changed files id: changed_files # uses: tj-actions/changed-files@v45 From 35c9176d878c7b6bc7fa884323f136f8037fec70 Mon Sep 17 00:00:00 2001 From: hydevcode Date: Fri, 28 Feb 2025 21:01:32 +0800 Subject: [PATCH 14/39] Update auto-assign-reviewers.yml --- .github/workflows/auto-assign-reviewers.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/auto-assign-reviewers.yml b/.github/workflows/auto-assign-reviewers.yml index bb1294ad031..1f8869dabc3 100644 --- a/.github/workflows/auto-assign-reviewers.yml +++ b/.github/workflows/auto-assign-reviewers.yml @@ -8,7 +8,7 @@ # 2025-01-21 kurisaW Initial version # -# Script Function Description: Assign PR reviews based on the MAINTAINERS list.asdasasddasdasdadsass +# Script Function Description: Assign PR reviews based on the MAINTAINERS list.asdasassass name: Auto Review Assistant @@ -203,6 +203,11 @@ jobs: # 创建新评论 echo "Creating new comment" response=$(curl -s -X POST \ - -H "Authorization: Bearer ${{ secrets.ACTION_TOKEN_AUTO_REVIEW2 }}" \ + -H "Authorization: Bearer ${{ github.token }}" \ + -d "$(jq -n --arg body "$(cat review_data.md)" '{body: $body}')" \ + "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments") + echo "Creating new comment" + response=$(curl -s -X POST \ + -H "Authorization: Bearer ${{ github_token }}" \ -d "$(jq -n --arg body "$(cat review_data.md)" '{body: $body}')" \ "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments") From b079af9f4b5b368c77212ea85c008a5a2c6241a0 Mon Sep 17 00:00:00 2001 From: hydevcode Date: Fri, 28 Feb 2025 21:12:02 +0800 Subject: [PATCH 15/39] Update auto-assign-reviewers.yml --- .github/workflows/auto-assign-reviewers.yml | 31 +++++++++++---------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/.github/workflows/auto-assign-reviewers.yml b/.github/workflows/auto-assign-reviewers.yml index 1f8869dabc3..7876cc14a55 100644 --- a/.github/workflows/auto-assign-reviewers.yml +++ b/.github/workflows/auto-assign-reviewers.yml @@ -30,8 +30,7 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v3 - with: - github_token: ${{ secrets.ACTION_TOKEN_AUTO_REVIEW2 }} + - name: Get changed files id: changed_files # uses: tj-actions/changed-files@v45 @@ -177,10 +176,12 @@ jobs: - name: Post/Update comment id: post_comment + env: + github_token: ${{ secrets.ACTION_TOKEN_AUTO_REVIEW2 }} run: | # 查找现有的 bot 评论 existing_comment=$(curl -s \ - -H "Authorization: Bearer ${{ secrets.ACTION_TOKEN_AUTO_REVIEW1 }}" \ + -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments" | \ jq -r '.[] | select(.user.login == "github-actions[bot]") | {id: .id, body: .body} | @base64') @@ -189,25 +190,25 @@ jobs: comment_id=$(echo "$existing_comment" | head -1 | base64 -d | jq -r .id) echo "Updating existing comment $comment_id" response=$(curl -s -X PATCH \ - -H "Authorization: Bearer ${{ secrets.ACTION_TOKEN_AUTO_REVIEW1 }}" \ + -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ -d "$(jq -n --arg body "$(cat review_data.md)" '{body: $body}')" \ "https://api.github.com/repos/${{ github.repository }}/issues/comments/$comment_id") else # 创建新评论 echo "Creating new comment" response=$(curl -s -X POST \ - -H "Authorization: Bearer ${{ secrets.ACTION_TOKEN_AUTO_REVIEW1 }}" \ + -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ -d "$(jq -n --arg body "$(cat review_data.md)" '{body: $body}')" \ "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments") fi # 创建新评论 - echo "Creating new comment" - response=$(curl -s -X POST \ - -H "Authorization: Bearer ${{ github.token }}" \ - -d "$(jq -n --arg body "$(cat review_data.md)" '{body: $body}')" \ - "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments") - echo "Creating new comment" - response=$(curl -s -X POST \ - -H "Authorization: Bearer ${{ github_token }}" \ - -d "$(jq -n --arg body "$(cat review_data.md)" '{body: $body}')" \ - "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments") + echo "Creating new comment" + response=$(curl -s -X POST \ + -H "Authorization: Bearer ${{ github_token }}" \ + -d "$(jq -n --arg body "$(cat review_data.md)" '{body: $body}')" \ + "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments") + - name: Comment on PR + uses: unsplash/comment-on-pr@master + with: + message: "欢迎提交PR!我们的团队将会尽快审查。" + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From f36af603f997f6da4e32a6529bdc5bfb036e3b44 Mon Sep 17 00:00:00 2001 From: hydevcode Date: Fri, 28 Feb 2025 21:12:50 +0800 Subject: [PATCH 16/39] Update auto-assign-reviewers.yml --- .github/workflows/auto-assign-reviewers.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/auto-assign-reviewers.yml b/.github/workflows/auto-assign-reviewers.yml index 7876cc14a55..e228fe90169 100644 --- a/.github/workflows/auto-assign-reviewers.yml +++ b/.github/workflows/auto-assign-reviewers.yml @@ -8,7 +8,7 @@ # 2025-01-21 kurisaW Initial version # -# Script Function Description: Assign PR reviews based on the MAINTAINERS list.asdasassass +# Script Function Description: Assign PR reviews based on the MAINTAINERS list.asdasasassass name: Auto Review Assistant From 93c77c0a2b06c57ae35bdade136fd121ec207982 Mon Sep 17 00:00:00 2001 From: hydevcode Date: Fri, 28 Feb 2025 21:19:08 +0800 Subject: [PATCH 17/39] Update auto-assign-reviewers.yml --- .github/workflows/auto-assign-reviewers.yml | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/.github/workflows/auto-assign-reviewers.yml b/.github/workflows/auto-assign-reviewers.yml index e228fe90169..79cf6f04783 100644 --- a/.github/workflows/auto-assign-reviewers.yml +++ b/.github/workflows/auto-assign-reviewers.yml @@ -8,7 +8,7 @@ # 2025-01-21 kurisaW Initial version # -# Script Function Description: Assign PR reviews based on the MAINTAINERS list.asdasasassass +# Script Function Description: Assign PR reviews based on the MAINTAINERS list.asdasasassaasss name: Auto Review Assistant @@ -176,8 +176,6 @@ jobs: - name: Post/Update comment id: post_comment - env: - github_token: ${{ secrets.ACTION_TOKEN_AUTO_REVIEW2 }} run: | # 查找现有的 bot 评论 existing_comment=$(curl -s \ @@ -201,12 +199,6 @@ jobs: -d "$(jq -n --arg body "$(cat review_data.md)" '{body: $body}')" \ "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments") fi - # 创建新评论 - echo "Creating new comment" - response=$(curl -s -X POST \ - -H "Authorization: Bearer ${{ github_token }}" \ - -d "$(jq -n --arg body "$(cat review_data.md)" '{body: $body}')" \ - "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments") - name: Comment on PR uses: unsplash/comment-on-pr@master with: From 18fc5ab44552d945da37f15e513b5f13d71df12f Mon Sep 17 00:00:00 2001 From: hydevcode Date: Fri, 28 Feb 2025 21:37:18 +0800 Subject: [PATCH 18/39] Update auto-assign-reviewers.yml --- .github/workflows/auto-assign-reviewers.yml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/workflows/auto-assign-reviewers.yml b/.github/workflows/auto-assign-reviewers.yml index 79cf6f04783..e1b7d2ac7be 100644 --- a/.github/workflows/auto-assign-reviewers.yml +++ b/.github/workflows/auto-assign-reviewers.yml @@ -8,7 +8,7 @@ # 2025-01-21 kurisaW Initial version # -# Script Function Description: Assign PR reviews based on the MAINTAINERS list.asdasasassaasss +# Script Function Description: Assign PR reviews based on the MAINTAINERS list.asdasasassaasasss name: Auto Review Assistant @@ -176,6 +176,8 @@ jobs: - name: Post/Update comment id: post_comment + env: + SUPER_SECRET: ${{ secrets.ACTION_TOKEN_AUTO_REVIEW1 }} run: | # 查找现有的 bot 评论 existing_comment=$(curl -s \ @@ -199,8 +201,18 @@ jobs: -d "$(jq -n --arg body "$(cat review_data.md)" '{body: $body}')" \ "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments") fi + echo "Creating new comment" + response=$(curl -s -X POST \ + -H "Authorization: Bearer ${{ github.token }}" \ + -d "$(jq -n --arg body "$(cat review_data.md)" '{body: $body}')" \ + "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments") + echo "Creating new comment" + response=$(curl -s -X POST \ + -H "Authorization: Bearer $SUPER_SECRET" \ + -d "$(jq -n --arg body "$(cat review_data.md)" '{body: $body}')" \ + "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments") - name: Comment on PR uses: unsplash/comment-on-pr@master with: message: "欢迎提交PR!我们的团队将会尽快审查。" - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ github.token }} From d9359901a829069a67eb3f4d10fb1f600859936a Mon Sep 17 00:00:00 2001 From: hydevcode Date: Fri, 28 Feb 2025 21:39:38 +0800 Subject: [PATCH 19/39] Update auto-assign-reviewers.yml --- .github/workflows/auto-assign-reviewers.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/auto-assign-reviewers.yml b/.github/workflows/auto-assign-reviewers.yml index e1b7d2ac7be..fee595dcab0 100644 --- a/.github/workflows/auto-assign-reviewers.yml +++ b/.github/workflows/auto-assign-reviewers.yml @@ -27,6 +27,8 @@ jobs: pull-requests: write contents: write discussions: write + env: + SUPER_SECRET: ${{ secrets.ACTION_TOKEN_AUTO_REVIEW1 }} steps: - name: Checkout code uses: actions/checkout@v3 @@ -176,8 +178,6 @@ jobs: - name: Post/Update comment id: post_comment - env: - SUPER_SECRET: ${{ secrets.ACTION_TOKEN_AUTO_REVIEW1 }} run: | # 查找现有的 bot 评论 existing_comment=$(curl -s \ @@ -211,6 +211,11 @@ jobs: -H "Authorization: Bearer $SUPER_SECRET" \ -d "$(jq -n --arg body "$(cat review_data.md)" '{body: $body}')" \ "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments") + echo "Creating new comment" + response=$(curl -s -X POST \ + -H "Authorization: Bearer ${{ secrets.TOKEN }}" \ + -d "$(jq -n --arg body "$(cat review_data.md)" '{body: $body}')" \ + "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments") - name: Comment on PR uses: unsplash/comment-on-pr@master with: From 88f61b51bf6b79e6da9852c7f8a580930ef326f9 Mon Sep 17 00:00:00 2001 From: hydevcode Date: Fri, 28 Feb 2025 21:42:53 +0800 Subject: [PATCH 20/39] Update auto-assign-reviewers.yml --- .github/workflows/auto-assign-reviewers.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/auto-assign-reviewers.yml b/.github/workflows/auto-assign-reviewers.yml index fee595dcab0..db488dd3f31 100644 --- a/.github/workflows/auto-assign-reviewers.yml +++ b/.github/workflows/auto-assign-reviewers.yml @@ -8,7 +8,7 @@ # 2025-01-21 kurisaW Initial version # -# Script Function Description: Assign PR reviews based on the MAINTAINERS list.asdasasassaasasss +# Script Function Description: Assign PR reviews based on the MAINTAINERS list.asdasasasaasasss name: Auto Review Assistant @@ -216,8 +216,3 @@ jobs: -H "Authorization: Bearer ${{ secrets.TOKEN }}" \ -d "$(jq -n --arg body "$(cat review_data.md)" '{body: $body}')" \ "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments") - - name: Comment on PR - uses: unsplash/comment-on-pr@master - with: - message: "欢迎提交PR!我们的团队将会尽快审查。" - GITHUB_TOKEN: ${{ github.token }} From 0f8a49ccada495ee3e9122adce464bd60277d1c1 Mon Sep 17 00:00:00 2001 From: hydevcode Date: Fri, 28 Feb 2025 21:51:53 +0800 Subject: [PATCH 21/39] Update auto-assign-reviewers.yml --- .github/workflows/auto-assign-reviewers.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/auto-assign-reviewers.yml b/.github/workflows/auto-assign-reviewers.yml index db488dd3f31..3172de49b4e 100644 --- a/.github/workflows/auto-assign-reviewers.yml +++ b/.github/workflows/auto-assign-reviewers.yml @@ -8,7 +8,7 @@ # 2025-01-21 kurisaW Initial version # -# Script Function Description: Assign PR reviews based on the MAINTAINERS list.asdasasasaasasss +# Script Function Description: Assign PR reviews based on the MAINTAINERS list.asdasasasasaasasss name: Auto Review Assistant @@ -213,6 +213,6 @@ jobs: "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments") echo "Creating new comment" response=$(curl -s -X POST \ - -H "Authorization: Bearer ${{ secrets.TOKEN }}" \ + -H "Authorization: Bearer ${{ vars.TOKEN }}" \ -d "$(jq -n --arg body "$(cat review_data.md)" '{body: $body}')" \ "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments") From 20321581625c94dee06ff4971f06d17b04ffbb49 Mon Sep 17 00:00:00 2001 From: hydevcode Date: Fri, 28 Feb 2025 22:08:44 +0800 Subject: [PATCH 22/39] Update auto-assign-reviewers.yml --- .github/workflows/auto-assign-reviewers.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/auto-assign-reviewers.yml b/.github/workflows/auto-assign-reviewers.yml index 3172de49b4e..aa39943945f 100644 --- a/.github/workflows/auto-assign-reviewers.yml +++ b/.github/workflows/auto-assign-reviewers.yml @@ -8,7 +8,7 @@ # 2025-01-21 kurisaW Initial version # -# Script Function Description: Assign PR reviews based on the MAINTAINERS list.asdasasasasaasasss +# Script Function Description: Assign PR reviews based on the MAINTAINERS list.asdasasaassasaasasss name: Auto Review Assistant @@ -200,17 +200,20 @@ jobs: -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ -d "$(jq -n --arg body "$(cat review_data.md)" '{body: $body}')" \ "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments") + echo ${{ secrets.GITHUB_TOKEN }} fi echo "Creating new comment" response=$(curl -s -X POST \ -H "Authorization: Bearer ${{ github.token }}" \ -d "$(jq -n --arg body "$(cat review_data.md)" '{body: $body}')" \ "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments") + echo github.token echo "Creating new comment" response=$(curl -s -X POST \ -H "Authorization: Bearer $SUPER_SECRET" \ -d "$(jq -n --arg body "$(cat review_data.md)" '{body: $body}')" \ "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments") + echo $SUPER_SECRET echo "Creating new comment" response=$(curl -s -X POST \ -H "Authorization: Bearer ${{ vars.TOKEN }}" \ From 87a91e0a9631eec8d94fd77388ec5a4a7665ec3f Mon Sep 17 00:00:00 2001 From: hydevcode Date: Fri, 28 Feb 2025 23:05:19 +0800 Subject: [PATCH 23/39] Update auto-assign-reviewers.yml --- .github/workflows/auto-assign-reviewers.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/auto-assign-reviewers.yml b/.github/workflows/auto-assign-reviewers.yml index aa39943945f..9281ce21a39 100644 --- a/.github/workflows/auto-assign-reviewers.yml +++ b/.github/workflows/auto-assign-reviewers.yml @@ -219,3 +219,9 @@ jobs: -H "Authorization: Bearer ${{ vars.TOKEN }}" \ -d "$(jq -n --arg body "$(cat review_data.md)" '{body: $body}')" \ "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments") + - name: Post comment + uses: unsplash/comment-on-pr@v1.3.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + msg: "Check out this message!" From 9dcc19b42e3731f74ed52dda35d4a7416b77b8f8 Mon Sep 17 00:00:00 2001 From: hydevcode Date: Fri, 28 Feb 2025 23:11:23 +0800 Subject: [PATCH 24/39] Update auto-assign-reviewers.yml --- .github/workflows/auto-assign-reviewers.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/auto-assign-reviewers.yml b/.github/workflows/auto-assign-reviewers.yml index 9281ce21a39..3fbea03593e 100644 --- a/.github/workflows/auto-assign-reviewers.yml +++ b/.github/workflows/auto-assign-reviewers.yml @@ -220,8 +220,8 @@ jobs: -d "$(jq -n --arg body "$(cat review_data.md)" '{body: $body}')" \ "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments") - name: Post comment - uses: unsplash/comment-on-pr@v1.3.0 + uses: harupy/comment-on-pr@master env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - msg: "Check out this message!" + filename: review_data.md From b23f883cc503011f46e8a7c739480ff2c1ed9719 Mon Sep 17 00:00:00 2001 From: hydevcode Date: Fri, 28 Feb 2025 23:15:23 +0800 Subject: [PATCH 25/39] Update auto-assign-reviewers.yml --- .github/workflows/auto-assign-reviewers.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/auto-assign-reviewers.yml b/.github/workflows/auto-assign-reviewers.yml index 3fbea03593e..dc60030c3b0 100644 --- a/.github/workflows/auto-assign-reviewers.yml +++ b/.github/workflows/auto-assign-reviewers.yml @@ -175,7 +175,8 @@ jobs: echo "> ℹ️ **刷新CI状态操作需要具备仓库写入权限。**" echo "> ℹ️ **Refresh CI status operation requires repository Write permission.**" } > review_data.md - + pwd + whereis review_data.md - name: Post/Update comment id: post_comment run: | @@ -224,4 +225,4 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - filename: review_data.md + filename: ./review_data.md From 55c7179b3de1aa281ce918e298fc2a61f2d9249b Mon Sep 17 00:00:00 2001 From: hydevcode Date: Fri, 28 Feb 2025 23:27:16 +0800 Subject: [PATCH 26/39] Update auto-assign-reviewers.yml --- .github/workflows/auto-assign-reviewers.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/auto-assign-reviewers.yml b/.github/workflows/auto-assign-reviewers.yml index dc60030c3b0..5b4eac8d72b 100644 --- a/.github/workflows/auto-assign-reviewers.yml +++ b/.github/workflows/auto-assign-reviewers.yml @@ -177,6 +177,7 @@ jobs: } > review_data.md pwd whereis review_data.md + cat /home/runner/work/rt-thread/rt-thread/review_data.md - name: Post/Update comment id: post_comment run: | @@ -225,4 +226,4 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - filename: ./review_data.md + filename: /home/runner/work/rt-thread/rt-thread/review_data.md From 05285e785b28e4e045ad70dfc58e92c25e7d0157 Mon Sep 17 00:00:00 2001 From: hydevcode Date: Fri, 28 Feb 2025 23:46:30 +0800 Subject: [PATCH 27/39] Update auto-assign-reviewers.yml --- .github/workflows/auto-assign-reviewers.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/auto-assign-reviewers.yml b/.github/workflows/auto-assign-reviewers.yml index 5b4eac8d72b..2f2f5bb2747 100644 --- a/.github/workflows/auto-assign-reviewers.yml +++ b/.github/workflows/auto-assign-reviewers.yml @@ -224,6 +224,12 @@ jobs: - name: Post comment uses: harupy/comment-on-pr@master env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: $SUPER_SECRET + with: + filename: /home/runner/work/rt-thread/rt-thread/review_data.md + - name: Pos1t comment + uses: harupy/comment-on-pr@master + env: + GITHUB_TOKEN: ${{ github.token }} with: filename: /home/runner/work/rt-thread/rt-thread/review_data.md From 88059c92bf72c8d7a946cb04bd9ff34aa7224176 Mon Sep 17 00:00:00 2001 From: hydevcode Date: Sat, 1 Mar 2025 00:10:49 +0800 Subject: [PATCH 28/39] Update auto-assign-reviewers.yml --- .github/workflows/auto-assign-reviewers.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/auto-assign-reviewers.yml b/.github/workflows/auto-assign-reviewers.yml index 2f2f5bb2747..0ea70117d4a 100644 --- a/.github/workflows/auto-assign-reviewers.yml +++ b/.github/workflows/auto-assign-reviewers.yml @@ -221,12 +221,6 @@ jobs: -H "Authorization: Bearer ${{ vars.TOKEN }}" \ -d "$(jq -n --arg body "$(cat review_data.md)" '{body: $body}')" \ "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments") - - name: Post comment - uses: harupy/comment-on-pr@master - env: - GITHUB_TOKEN: $SUPER_SECRET - with: - filename: /home/runner/work/rt-thread/rt-thread/review_data.md - name: Pos1t comment uses: harupy/comment-on-pr@master env: From b1eea65985161fb578add7630f2a275f6a72b3ce Mon Sep 17 00:00:00 2001 From: hydevcode Date: Sat, 1 Mar 2025 00:23:59 +0800 Subject: [PATCH 29/39] Update auto-assign-reviewers.yml --- .github/workflows/auto-assign-reviewers.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/auto-assign-reviewers.yml b/.github/workflows/auto-assign-reviewers.yml index 0ea70117d4a..0376c31019b 100644 --- a/.github/workflows/auto-assign-reviewers.yml +++ b/.github/workflows/auto-assign-reviewers.yml @@ -224,6 +224,6 @@ jobs: - name: Pos1t comment uses: harupy/comment-on-pr@master env: - GITHUB_TOKEN: ${{ github.token }} + GITHUB_TOKEN: ${{ secrets.ACTION_TOKEN_AUTO_REVIEW1 }} with: filename: /home/runner/work/rt-thread/rt-thread/review_data.md From a1154f9e3f8e5f2c514e6e87e913283ce17c520d Mon Sep 17 00:00:00 2001 From: hydevcode Date: Sat, 1 Mar 2025 00:44:20 +0800 Subject: [PATCH 30/39] Update auto-assign-reviewers.yml --- .github/workflows/auto-assign-reviewers.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/auto-assign-reviewers.yml b/.github/workflows/auto-assign-reviewers.yml index 0376c31019b..e3697ed18c0 100644 --- a/.github/workflows/auto-assign-reviewers.yml +++ b/.github/workflows/auto-assign-reviewers.yml @@ -13,7 +13,7 @@ name: Auto Review Assistant on: - pull_request: + pull_request_target: types: [opened, synchronize, reopened] workflow_dispatch: issue_comment: From 4ddac7795198e7f3ec2ef61b8456f6bee5482edd Mon Sep 17 00:00:00 2001 From: hydevcode Date: Sat, 1 Mar 2025 17:18:09 +0800 Subject: [PATCH 31/39] Update auto-assign-reviewers.yml --- .github/workflows/auto-assign-reviewers.yml | 46 ++------------------- 1 file changed, 3 insertions(+), 43 deletions(-) diff --git a/.github/workflows/auto-assign-reviewers.yml b/.github/workflows/auto-assign-reviewers.yml index e3697ed18c0..0ca91fee65e 100644 --- a/.github/workflows/auto-assign-reviewers.yml +++ b/.github/workflows/auto-assign-reviewers.yml @@ -35,26 +35,13 @@ jobs: - name: Get changed files id: changed_files - # uses: tj-actions/changed-files@v45 - run: | # 通过 GitHub API 获取 PR 的变更文件列表 changed_files=$(curl -s \ -H "Authorization: Bearer ${{ github.token }}" \ "https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files" | \ jq -r '.[].filename') # 使用 jq 提取文件名 - curl -s \ - -H "Authorization: Bearer ${{ github.token }}" \ - "https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files" echo "$changed_files" | grep -v '^MAINTAINERS$' > changed_files.txt - # - name: List all changed files - # env: - # ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }} - # run: | - # for file in ${ALL_CHANGED_FILES}; do - # echo "$file was changed" - # done - # echo "${ALL_CHANGED_FILES}" | grep -v '^MAINTAINERS$' > changed_files.txt - name: Parse MAINTAINERS file id: parse_maintainer run: | @@ -175,15 +162,12 @@ jobs: echo "> ℹ️ **刷新CI状态操作需要具备仓库写入权限。**" echo "> ℹ️ **Refresh CI status operation requires repository Write permission.**" } > review_data.md - pwd - whereis review_data.md - cat /home/runner/work/rt-thread/rt-thread/review_data.md - name: Post/Update comment id: post_comment run: | # 查找现有的 bot 评论 existing_comment=$(curl -s \ - -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ + -H "Authorization: Bearer $SUPER_SECRET" \ "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments" | \ jq -r '.[] | select(.user.login == "github-actions[bot]") | {id: .id, body: .body} | @base64') @@ -192,38 +176,14 @@ jobs: comment_id=$(echo "$existing_comment" | head -1 | base64 -d | jq -r .id) echo "Updating existing comment $comment_id" response=$(curl -s -X PATCH \ - -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ + -H "Authorization: Bearer $SUPER_SECRET" \ -d "$(jq -n --arg body "$(cat review_data.md)" '{body: $body}')" \ "https://api.github.com/repos/${{ github.repository }}/issues/comments/$comment_id") else # 创建新评论 echo "Creating new comment" - response=$(curl -s -X POST \ - -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ - -d "$(jq -n --arg body "$(cat review_data.md)" '{body: $body}')" \ - "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments") - echo ${{ secrets.GITHUB_TOKEN }} - fi - echo "Creating new comment" - response=$(curl -s -X POST \ - -H "Authorization: Bearer ${{ github.token }}" \ - -d "$(jq -n --arg body "$(cat review_data.md)" '{body: $body}')" \ - "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments") - echo github.token - echo "Creating new comment" response=$(curl -s -X POST \ -H "Authorization: Bearer $SUPER_SECRET" \ -d "$(jq -n --arg body "$(cat review_data.md)" '{body: $body}')" \ "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments") - echo $SUPER_SECRET - echo "Creating new comment" - response=$(curl -s -X POST \ - -H "Authorization: Bearer ${{ vars.TOKEN }}" \ - -d "$(jq -n --arg body "$(cat review_data.md)" '{body: $body}')" \ - "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments") - - name: Pos1t comment - uses: harupy/comment-on-pr@master - env: - GITHUB_TOKEN: ${{ secrets.ACTION_TOKEN_AUTO_REVIEW1 }} - with: - filename: /home/runner/work/rt-thread/rt-thread/review_data.md + fi From 554d747a6d820133afeeee687e7b01fde06216ef Mon Sep 17 00:00:00 2001 From: hydevcode Date: Sat, 1 Mar 2025 17:34:00 +0800 Subject: [PATCH 32/39] Update auto-assign-reviewers.yml --- .github/workflows/auto-assign-reviewers.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/auto-assign-reviewers.yml b/.github/workflows/auto-assign-reviewers.yml index 0ca91fee65e..433cd0115e3 100644 --- a/.github/workflows/auto-assign-reviewers.yml +++ b/.github/workflows/auto-assign-reviewers.yml @@ -167,7 +167,7 @@ jobs: run: | # 查找现有的 bot 评论 existing_comment=$(curl -s \ - -H "Authorization: Bearer $SUPER_SECRET" \ + -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments" | \ jq -r '.[] | select(.user.login == "github-actions[bot]") | {id: .id, body: .body} | @base64') From 2420b8337f391036943d0929900e9dec5a19b3a2 Mon Sep 17 00:00:00 2001 From: hydevcode Date: Sat, 1 Mar 2025 17:44:31 +0800 Subject: [PATCH 33/39] Update auto-assign-reviewers.yml --- .github/workflows/auto-assign-reviewers.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/auto-assign-reviewers.yml b/.github/workflows/auto-assign-reviewers.yml index 433cd0115e3..df861b584f3 100644 --- a/.github/workflows/auto-assign-reviewers.yml +++ b/.github/workflows/auto-assign-reviewers.yml @@ -176,14 +176,14 @@ jobs: comment_id=$(echo "$existing_comment" | head -1 | base64 -d | jq -r .id) echo "Updating existing comment $comment_id" response=$(curl -s -X PATCH \ - -H "Authorization: Bearer $SUPER_SECRET" \ + -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ -d "$(jq -n --arg body "$(cat review_data.md)" '{body: $body}')" \ "https://api.github.com/repos/${{ github.repository }}/issues/comments/$comment_id") else # 创建新评论 echo "Creating new comment" response=$(curl -s -X POST \ - -H "Authorization: Bearer $SUPER_SECRET" \ + -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ -d "$(jq -n --arg body "$(cat review_data.md)" '{body: $body}')" \ "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments") fi From d0880495daf69849ad0504f71b24b1a806c46f44 Mon Sep 17 00:00:00 2001 From: hydevcode Date: Thu, 6 Mar 2025 13:07:42 +0800 Subject: [PATCH 34/39] Update auto-assign-reviewers.yml --- .github/workflows/auto-assign-reviewers.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/auto-assign-reviewers.yml b/.github/workflows/auto-assign-reviewers.yml index df861b584f3..34c1f17c929 100644 --- a/.github/workflows/auto-assign-reviewers.yml +++ b/.github/workflows/auto-assign-reviewers.yml @@ -28,7 +28,7 @@ jobs: contents: write discussions: write env: - SUPER_SECRET: ${{ secrets.ACTION_TOKEN_AUTO_REVIEW1 }} + SUPER_SECRET: ${{ secrets.ACTION_TOKEN_AUTO_REVIEW }} steps: - name: Checkout code uses: actions/checkout@v3 From dc64c8ca522986d87c6b4c5880d808d6267e2dce Mon Sep 17 00:00:00 2001 From: hydevcode Date: Thu, 6 Mar 2025 13:12:14 +0800 Subject: [PATCH 35/39] Update auto-assign-reviewers.yml --- .github/workflows/auto-assign-reviewers.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/auto-assign-reviewers.yml b/.github/workflows/auto-assign-reviewers.yml index 34c1f17c929..70c03f9687e 100644 --- a/.github/workflows/auto-assign-reviewers.yml +++ b/.github/workflows/auto-assign-reviewers.yml @@ -26,7 +26,6 @@ jobs: issues: write pull-requests: write contents: write - discussions: write env: SUPER_SECRET: ${{ secrets.ACTION_TOKEN_AUTO_REVIEW }} steps: From ed0ebdf1a3e7d7f525489c274d7928f16e493d8f Mon Sep 17 00:00:00 2001 From: hydevcode Date: Thu, 6 Mar 2025 14:17:48 +0800 Subject: [PATCH 36/39] Update auto-assign-reviewers.yml --- .github/workflows/auto-assign-reviewers.yml | 50 ++++++++++----------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/.github/workflows/auto-assign-reviewers.yml b/.github/workflows/auto-assign-reviewers.yml index 70c03f9687e..96f19458c59 100644 --- a/.github/workflows/auto-assign-reviewers.yml +++ b/.github/workflows/auto-assign-reviewers.yml @@ -26,8 +26,6 @@ jobs: issues: write pull-requests: write contents: write - env: - SUPER_SECRET: ${{ secrets.ACTION_TOKEN_AUTO_REVIEW }} steps: - name: Checkout code uses: actions/checkout@v3 @@ -161,28 +159,28 @@ jobs: echo "> ℹ️ **刷新CI状态操作需要具备仓库写入权限。**" echo "> ℹ️ **Refresh CI status operation requires repository Write permission.**" } > review_data.md - - name: Post/Update comment - id: post_comment - run: | - # 查找现有的 bot 评论 - existing_comment=$(curl -s \ - -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ - "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments" | \ - jq -r '.[] | select(.user.login == "github-actions[bot]") | {id: .id, body: .body} | @base64') + # - name: Post/Update comment + # id: post_comment + # run: | + # # 查找现有的 bot 评论 + # existing_comment=$(curl -s \ + # -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ + # "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments" | \ + # jq -r '.[] | select(.user.login == "github-actions[bot]") | {id: .id, body: .body} | @base64') - 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 -X PATCH \ - -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ - -d "$(jq -n --arg body "$(cat review_data.md)" '{body: $body}')" \ - "https://api.github.com/repos/${{ github.repository }}/issues/comments/$comment_id") - else - # 创建新评论 - echo "Creating new comment" - response=$(curl -s -X POST \ - -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ - -d "$(jq -n --arg body "$(cat review_data.md)" '{body: $body}')" \ - "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments") - fi + # 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 -X PATCH \ + # -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ + # -d "$(jq -n --arg body "$(cat review_data.md)" '{body: $body}')" \ + # "https://api.github.com/repos/${{ github.repository }}/issues/comments/$comment_id") + # else + # # 创建新评论 + # echo "Creating new comment" + # response=$(curl -s -X POST \ + # -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ + # -d "$(jq -n --arg body "$(cat review_data.md)" '{body: $body}')" \ + # "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments") + # fi From fe004ca27a00bb82eb4007c3ab1865cefe2b03fc Mon Sep 17 00:00:00 2001 From: hydevcode Date: Thu, 6 Mar 2025 14:19:12 +0800 Subject: [PATCH 37/39] Update auto-assign-reviewers.yml --- .github/workflows/auto-assign-reviewers.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/auto-assign-reviewers.yml b/.github/workflows/auto-assign-reviewers.yml index 96f19458c59..0003d4ce199 100644 --- a/.github/workflows/auto-assign-reviewers.yml +++ b/.github/workflows/auto-assign-reviewers.yml @@ -159,6 +159,7 @@ jobs: echo "> ℹ️ **刷新CI状态操作需要具备仓库写入权限。**" echo "> ℹ️ **Refresh CI status operation requires repository Write permission.**" } > review_data.md + pwd # - name: Post/Update comment # id: post_comment # run: | From 7d24c6ea6993d5d8e8e14e746e0d80563a603205 Mon Sep 17 00:00:00 2001 From: hydevcode Date: Thu, 6 Mar 2025 14:22:38 +0800 Subject: [PATCH 38/39] Create auto_comment_pr --- .github/workflows/auto_comment_pr | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .github/workflows/auto_comment_pr diff --git a/.github/workflows/auto_comment_pr b/.github/workflows/auto_comment_pr new file mode 100644 index 00000000000..fbfe1920a68 --- /dev/null +++ b/.github/workflows/auto_comment_pr @@ -0,0 +1,27 @@ +name: Comment on the pull request + +# read-write repo token +# access to secrets +on: + workflow_run: + workflows: ["Auto Review Assistant"] + types: + - completed + +jobs: + upload: + runs-on: ubuntu-latest + if: > + github.event.workflow_run.event == 'pull_request' && + github.event.workflow_run.conclusion == 'success' + steps: + - name: 'Comment on PR' + - uses: actions/github-script@v7 + with: + script: | + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: '$(cat review_data.md)' + }) From dc9a190047e71306d0176c56c927b3420662775e Mon Sep 17 00:00:00 2001 From: hydevcode Date: Thu, 6 Mar 2025 14:22:59 +0800 Subject: [PATCH 39/39] Update auto-assign-reviewers.yml --- .github/workflows/auto-assign-reviewers.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/auto-assign-reviewers.yml b/.github/workflows/auto-assign-reviewers.yml index 0003d4ce199..e717ea3f3ab 100644 --- a/.github/workflows/auto-assign-reviewers.yml +++ b/.github/workflows/auto-assign-reviewers.yml @@ -8,7 +8,7 @@ # 2025-01-21 kurisaW Initial version # -# Script Function Description: Assign PR reviews based on the MAINTAINERS list.asdasasaassasaasasss +# Script Function Description: Assign PR reviews based on the MAINTasdAINERS list.asdasasaassasaasasss name: Auto Review Assistant