-
-
Notifications
You must be signed in to change notification settings - Fork 676
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: refactor notify triager workflow #3403
Changes from all commits
9758be5
3961fef
f267006
4fa6294
cb72017
6223409
c44dbec
b0bbf6c
097ad18
541568c
55a0c57
5268cfb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -17,7 +17,10 @@ jobs: | |||||||||||||||||||||||
- name: Get commit message | ||||||||||||||||||||||||
id: commit-message | ||||||||||||||||||||||||
run: | | ||||||||||||||||||||||||
# Extract the commit message | ||||||||||||||||||||||||
commit_message=$(git log --format=%B -n 1 ${{ github.event.pull_request.head.sha }}) | ||||||||||||||||||||||||
commit_message=$(echo "$commit_message" | tr '\n' ' ') | ||||||||||||||||||||||||
commit_message=$(echo "$commit_message" | sed 's/[<>|]//g' | sed 's/[][]//g' | sed 's/(//g' | sed 's/)//g' | xargs) | ||||||||||||||||||||||||
Comment on lines
+20
to
+23
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Improve commit message extraction robustness and efficiency The commit message extraction and cleaning can be improved for better robustness and efficiency. - commit_message=$(git log --format=%B -n 1 ${{ github.event.pull_request.head.sha }})
- commit_message=$(echo "$commit_message" | tr '\n' ' ')
- commit_message=$(echo "$commit_message" | sed 's/[<>|]//g' | sed 's/[][]//g' | sed 's/(//g' | sed 's/)//g' | xargs)
+ if ! commit_message=$(git log --format=%B -n 1 "${{ github.event.pull_request.head.sha }}"); then
+ echo "::error::Failed to extract commit message"
+ exit 1
+ fi
+ commit_message=$(echo "$commit_message" | tr '\n' ' ' | sed 's/[<>|()[\]]//g' | xargs)
echo "commit_message=$commit_message" >> $GITHUB_OUTPUT Changes:
📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||
echo "commit_message=$commit_message" >> $GITHUB_OUTPUT | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
- name: Check if last commit is a merge commit | ||||||||||||||||||||||||
|
@@ -41,6 +44,7 @@ jobs: | |||||||||||||||||||||||
files: | | ||||||||||||||||||||||||
**.md | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
|
||||||||||||||||||||||||
- name: Check PR Changes for non-.md files | ||||||||||||||||||||||||
id: non-md-pr-changes | ||||||||||||||||||||||||
uses: tj-actions/changed-files@aa08304bd477b800d468db44fe10f6c61f7f7b11 # version 42.1.0 https://github.com/tj-actions/changed-files/releases/tag/v42.1.0 | ||||||||||||||||||||||||
|
@@ -68,8 +72,9 @@ jobs: | |||||||||||||||||||||||
echo "codeTriagers=$codeTriagers" >> $GITHUB_ENV | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
- name: Add Reviewers for code files | ||||||||||||||||||||||||
if: steps.check-merge-branch.outputs.isMergeCommit == 'false' && steps.non-md-pr-changes.outputs.any_changed == 'true' | ||||||||||||||||||||||||
if: steps.non-md-pr-changes.outputs.any_changed == 'true' | ||||||||||||||||||||||||
run: | | ||||||||||||||||||||||||
echo "Hello1" | ||||||||||||||||||||||||
IFS=' ' read -r -a codeTriagers <<< "${{ env.codeTriagers }}" | ||||||||||||||||||||||||
reviewers=$(printf ', "%s"' "${codeTriagers[@]}") | ||||||||||||||||||||||||
reviewers=[${reviewers:2}] | ||||||||||||||||||||||||
|
@@ -83,8 +88,9 @@ jobs: | |||||||||||||||||||||||
}" | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
- name: Add Reviewers for doc files | ||||||||||||||||||||||||
if: steps.check-merge-branch.outputs.isMergeCommit == 'false' && steps.md-pr-changes.outputs.any_changed == 'true' | ||||||||||||||||||||||||
if: steps.md-pr-changes.outputs.any_changed == 'true' | ||||||||||||||||||||||||
run: | | ||||||||||||||||||||||||
echo "Hello" | ||||||||||||||||||||||||
IFS=' ' read -r -a docTriagers <<< "${{ env.docTriagers }}" | ||||||||||||||||||||||||
reviewers=$(printf ', "%s"' "${docTriagers[@]}") | ||||||||||||||||||||||||
reviewers=[${reviewers:2}] | ||||||||||||||||||||||||
|
@@ -96,3 +102,4 @@ jobs: | |||||||||||||||||||||||
-d "{ | ||||||||||||||||||||||||
\"reviewers\": $reviewers | ||||||||||||||||||||||||
}" | ||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the previous implementation of notify traiger workflow, we were getting doc triagers assigned to the PRs that didn't contain any doc changes. This was because of how the workflow was checking for file changes in the PR.
For example, in previous implementation:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it was because of MD file changes