Skip to content

Commit 9392108

Browse files
authored
Comment ion PR just opened (#13522)
* Comment ion PR just opened * Add silent fail
1 parent f52fcb4 commit 9392108

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

.github/ghprcomment.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,16 @@
154154
See [CONTRIBUTING.md](https://github.com/JabRef/jabref/blob/main/CONTRIBUTING.md#pull-request-process) for more details.
155155
156156
157-
# PR text
157+
# PR hygiene
158+
159+
- jobName: 'Ensure that contributor is assigned (fails if not commented on issue)'
160+
workflowName: 'On PR opened/updated'
161+
message: >
162+
You did not assign yourself to the issue.
163+
Thus, it looks like you skipped reading our [CONTRIBUTING.md](https://github.com/JabRef/jabref/blob/main/CONTRIBUTING.md), which explains exactly how to participate. No worries, it happens to the best of us.
164+
165+
166+
Give it a read, and you’ll discover the ancient wisdom of assigning issues to yourself. Trust me, it’s worth it. 🚀
158167
159168
- jobName: 'PR title must not start with "Fix for issue <number>"'
160169
workflowName: 'PR Tests'

.github/workflows/on-pr-opened-updated.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ jobs:
8585
skip-if-not-in-project: true
8686
ensure_assignment:
8787
name: Ensure that contributor is assigned (fails if not commented on issue)
88+
if: github.event.pull_request.head.repo.full_name != 'JabRef/jabref'
8889
# after determine_issue_number to ensure that there is only one failure because of no ticket number
8990
needs: determine_issue_number
9091
runs-on: ubuntu-latest
@@ -114,10 +115,22 @@ jobs:
114115
# Append the new assignee
115116
UPDATED_ASSIGNEES=$(echo "$ASSIGNEES" | jq --arg new "${{ github.event.pull_request.user.login }}" '. + [$new]')
116117
118+
LABELS=$(gh api repos/${{ github.repository }}/issues/${{ needs.determine_issue_number.outputs.issue_number }}/labels --jq '.[].name')
119+
if echo "$LABELS" | grep -q "^good"; then
120+
echo "✅ label good found"
121+
SILENT=false
122+
else
123+
echo "🚫 Silent fail if not possible to add assignee"
124+
SILENT=true
125+
fi
126+
117127
# Update issue with the new assignee list
118128
echo "Updating issue #${{ needs.determine_issue_number.outputs.issue_number }} updated with assignees: $UPDATED_ASSIGNEES..."
119-
gh api -X PATCH /repos/JabRef/jabref/issues/${{ needs.determine_issue_number.outputs.issue_number }} --input <(echo "{\"assignees\": $UPDATED_ASSIGNEES}")
120-
129+
if [ "$SILENT" = true ]; then
130+
gh api -X PATCH /repos/JabRef/jabref/issues/${{ needs.determine_issue_number.outputs.issue_number }} --input <(echo "{\"assignees\": $UPDATED_ASSIGNEES}") || true
131+
else
132+
gh api -X PATCH /repos/JabRef/jabref/issues/${{ needs.determine_issue_number.outputs.issue_number }} --input <(echo "{\"assignees\": $UPDATED_ASSIGNEES}")
133+
fi
121134
env:
122135
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
123136
- name: Add label "📌 Pinned"

0 commit comments

Comments
 (0)