Skip to content

Commit 418d3b3

Browse files
authored
Merge pull request #23662 from LaurelineP/core/update-prereview
Update workflow
2 parents ecce9e3 + 8666c86 commit 418d3b3

File tree

2 files changed

+25
-24
lines changed

2 files changed

+25
-24
lines changed

.github/workflows/pre-review.yml

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
python-version: 3.9
3434

3535

36-
- name: Fecth branch
36+
- name: Fetch branch
3737
run: git fetch origin ${{ github.event.pull_request.base.ref }}
3838

3939
- name: Collect information
@@ -64,49 +64,50 @@ jobs:
6464
- name: Run "preReview" script
6565
run: |
6666
PR_NUMBER=${{ github.event.pull_request.number }}
67+
BASE_REPO=${{ github.event.pull_request.base.repo.full_name }}
6768
REVIEW_MESSAGE=$(python pre_review.py "$CHANGED_FILES" "$CONTRIBUTOR")
6869
echo "REVIEW_MESSAGE<<EOF" >> $GITHUB_ENV
6970
echo "$REVIEW_MESSAGE" >> $GITHUB_ENV
7071
echo "EOF" >> $GITHUB_ENV
7172
72-
# Save to env
73-
echo "REVIEW_MESSAGE<<EOF" >> $GITHUB_ENV
74-
echo "$REVIEW_MESSAGE" >> $GITHUB_ENV
75-
echo "EOF" >> $GITHUB_ENV
76-
77-
# Print to log explicitly
7873
echo "===== REVIEW_MESSAGE ====="
7974
echo "$REVIEW_MESSAGE"
80-
echo "=========================="
75+
echo "==========================="
8176
8277
# Attempt to comment (will skip for forks)
83-
gh pr comment "$PR_NUMBER" --body "$REVIEW_MESSAGE" -R "${{ github.event.pull_request.base.repo.full_name }}"
84-
85-
# Assign invalid label
86-
if echo "$REVIEW_MESSAGE" | grep -Eqi 'Missing required contribution:|Incorrect changes:'; then
87-
gh pr edit "$PR_NUMBER" --add-label "invalid" -R "$BASE_REPO"
78+
gh pr comment "$PR_NUMBER" --body "$REVIEW_MESSAGE" -R "$BASE_REPO"
79+
80+
# --------------------------------------------------------------------------
81+
# LABELS
82+
# --------------------------------------------------------------------------
83+
# --- "Changes Requested" or "Awaiting Maintainer Validation" labels ---
84+
if echo "$REVIEW_MESSAGE" | grep -Eq '\- \[ \]'; then
85+
gh pr edit "$PR_NUMBER" --add-label "Changes Requested" -R "$BASE_REPO"
86+
gh pr edit "$PR_NUMBER" --remove-label "Awaiting Maintainer Validation" -R "$BASE_REPO"
8887
else
89-
gh pr edit "$PR_NUMBER" --remove-label "invalid" -R "$BASE_REPO"
88+
gh pr edit "$PR_NUMBER" --add-label "Awaiting Maintainer Validation" -R "$BASE_REPO"
89+
gh pr edit "$PR_NUMBER" --remove-label "Changes Requested" -R "$BASE_REPO"
9090
fi
9191
92-
# Assign changes requested label
93-
if echo "$REVIEW_MESSAGE" | grep -Eqi 'Contributors.md'; then
94-
gh pr edit "$PR_NUMBER" --add-label "changes requested" -R "$BASE_REPO"
92+
93+
# --- Invalid label ---
94+
if echo "$REVIEW_MESSAGE" | grep -qi 'Missing required contribution'; then
95+
gh pr edit "$PR_NUMBER" --add-label "invalid" -R "$BASE_REPO"
9596
else
96-
gh pr edit "$PR_NUMBER" --remove-label "changes requested" -R "$BASE_REPO"
97+
gh pr edit "$PR_NUMBER" --remove-label "invalid" -R "$BASE_REPO"
9798
fi
9899
99-
# Assign Awaiting Maintainer Validation if there are checkboxes
100-
if echo "$REVIEW_MESSAGE" | grep -q '\- \[ \]'; then
101-
gh pr edit "$PR_NUMBER" --add-label "Awaiting Maintainer Validation" -R "$BASE_REPO"
100+
101+
# --- Conflict present label ---
102+
if echo "$REVIEW_MESSAGE" | grep -qi 'archived'; then
103+
gh pr edit "$PR_NUMBER" --add-label "Conflict present" -R "$BASE_REPO"
102104
else
103-
gh pr edit "$PR_NUMBER" --remove-label "Awaiting Maintainer Validation" -R "$BASE_REPO"
105+
gh pr edit "$PR_NUMBER" --remove-label "Conflict present" -R "$BASE_REPO"
104106
fi
105107
106108
env:
107109
CHANGED_FILES: ${{ env.CHANGED_FILES }}
108110
CONTRIBUTOR: ${{ env.CONTRIBUTOR }}
109-
PR_NUMBERS: ${{ env.GITHUB_TOKEN }}
110111
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
111112

112113
remove-awaiting-on-merge:

pre_review.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def review_contributors_file( changed_files, contributor ):
159159

160160
if reviews:
161161
reviews = [
162-
'## `Contributors.md` addition feedback',
162+
'## `CONTRIBUTORS.md` addition feedback',
163163
'> [!TIP]',
164164
'> Check how others set their links to adjust yours if needed',
165165
*reviews

0 commit comments

Comments
 (0)