Skip to content

Commit dc80b3d

Browse files
authored
Update doc_review.yml
1 parent 48f72c4 commit dc80b3d

File tree

1 file changed

+28
-7
lines changed

1 file changed

+28
-7
lines changed

.github/workflows/doc_review.yml

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,36 @@ jobs:
8080
id: diff
8181
run: |
8282
echo "Getting PR diff to check file paths..."
83+
echo "Event name: ${{ github.event_name }}"
8384
84-
PR_NUMBER=$(jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH" || jq --raw-output .issue.number "$GITHUB_EVENT_PATH")
85+
# For debugging
86+
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
87+
echo "Workflow triggered manually by workflow_dispatch"
88+
# For workflow_dispatch, we need to check if we're on a PR branch
89+
if [[ "${{ github.ref }}" =~ ^refs/pull/([0-9]+)/merge$ ]]; then
90+
PR_NUMBER="${BASH_REMATCH[1]}"
91+
echo "Extracted PR number from github.ref: $PR_NUMBER"
92+
else
93+
echo "Not running on a PR branch: ${{ github.ref }}"
94+
# Set default counts for workflow_dispatch not on PR branch
95+
echo "zh_files_count=1" >> $GITHUB_OUTPUT
96+
echo "en_files_count=1" >> $GITHUB_OUTPUT
97+
exit 0
98+
fi
99+
else
100+
# For issue_comment event
101+
PR_NUMBER=$(jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH" || jq --raw-output .issue.number "$GITHUB_EVENT_PATH")
102+
echo "Extracted PR number from event path: $PR_NUMBER"
103+
fi
85104
86-
if [[ -n "$PR_NUMBER" ]]; then
105+
if [[ -n "$PR_NUMBER" && "$PR_NUMBER" != "null" ]]; then
106+
echo "Using PR number: $PR_NUMBER"
87107
# Get the list of changed files
88108
FILES=$(gh pr view $PR_NUMBER --repo ${{ github.repository }} --json files --jq '.files[].path')
89109
90110
# Count files in zh/ and en/ directories
91-
ZH_COUNT=$(echo "$FILES" | grep -c "^zh/")
92-
EN_COUNT=$(echo "$FILES" | grep -c "^en/")
111+
ZH_COUNT=$(echo "$FILES" | grep -c "^zh/" || echo "0")
112+
EN_COUNT=$(echo "$FILES" | grep -c "^en/" || echo "0")
93113
94114
echo "Changed files in PR #$PR_NUMBER:"
95115
echo "Files in zh/: $ZH_COUNT"
@@ -98,9 +118,10 @@ jobs:
98118
echo "zh_files_count=$ZH_COUNT" >> $GITHUB_OUTPUT
99119
echo "en_files_count=$EN_COUNT" >> $GITHUB_OUTPUT
100120
else
101-
echo "Could not determine PR number, setting defaults"
102-
echo "zh_files_count=0" >> $GITHUB_OUTPUT
103-
echo "en_files_count=0" >> $GITHUB_OUTPUT
121+
echo "Could not determine PR number, setting defaults for review"
122+
# Set default counts to trigger both reviewers for testing
123+
echo "zh_files_count=1" >> $GITHUB_OUTPUT
124+
echo "en_files_count=1" >> $GITHUB_OUTPUT
104125
fi
105126
env:
106127
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)