Skip to content

Commit bead71a

Browse files
committed
ci: use sticky-pull-request-comment for updating PR comment (#35160)
Replace custom PR comment update logic with `marocchino/sticky-pull-request-comment` for consistency across workflows
1 parent b90a1d0 commit bead71a

File tree

1 file changed

+18
-41
lines changed

1 file changed

+18
-41
lines changed

.github/workflows/label_new_contributor.yml

Lines changed: 18 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,14 @@ jobs:
2424
contents: read
2525
steps:
2626
- name: Label PR and report count
27+
id: contributor-check
2728
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
2829
with:
2930
script: |
3031
const MIN_MERGED = 5;
3132
const creator = context.payload.sender.login;
3233
const { owner, repo } = context.repo;
34+
core.setOutput('should_welcome', 'false');
3335
3436
console.log(`Checking closed issues for user: ${creator}`);
3537
@@ -77,47 +79,7 @@ jobs:
7779
repo,
7880
labels: ['new-contributor']
7981
});
80-
81-
// Check if we already posted a welcome comment (idempotency)
82-
const WELCOME_MARKER = '<!-- mathlib-welcome-comment -->';
83-
let alreadyWelcomed = false;
84-
for await (const response of github.paginate.iterator(
85-
github.rest.issues.listComments,
86-
{
87-
issue_number: context.issue.number,
88-
owner,
89-
repo,
90-
per_page: 100,
91-
}
92-
)) {
93-
if (response.data.some(c => c.body.includes(WELCOME_MARKER))) {
94-
alreadyWelcomed = true;
95-
break;
96-
}
97-
}
98-
99-
if (!alreadyWelcomed) {
100-
console.log('Posting welcome comment for new contributor...');
101-
const body = [
102-
WELCOME_MARKER,
103-
'## Welcome new contributor!',
104-
'Thank you for contributing to Mathlib! If you haven\'t done so already, please review our [contribution guidelines](https://leanprover-community.github.io/contribute/index.html), as well as the [style guide](https://leanprover-community.github.io/contribute/style.html) and [naming conventions](https://leanprover-community.github.io/contribute/naming.html).',
105-
'',
106-
'We use a [review queue](https://leanprover-community.github.io/queueboard/review_dashboard.html) to manage reviews. If your PR does not appear there, it is probably because it is not successfully building (i.e., it doesn\'t have a green checkmark), has the `awaiting-author` tag, or another reason described in the [Lifecycle of a PR](https://leanprover-community.github.io/contribute/index.html#lifecycle-of-a-pr).',
107-
'',
108-
'If you haven\'t already done so, please come to [https://leanprover.zulipchat.com/](https://leanprover.zulipchat.com/), introduce yourself, and mention your new PR.',
109-
'',
110-
'Thank you again for joining our community.',
111-
].join('\n');
112-
await github.rest.issues.createComment({
113-
issue_number: context.issue.number,
114-
owner,
115-
repo,
116-
body,
117-
});
118-
} else {
119-
console.log('Welcome comment already exists, skipping.');
120-
}
82+
core.setOutput('should_welcome', 'true');
12183
}
12284
12385
console.log('Creating check run with a message about the PR count by this author...');
@@ -134,3 +96,18 @@ jobs:
13496
summary: message,
13597
},
13698
});
99+
100+
- name: Post welcome comment for new contributor
101+
if: steps.contributor-check.outputs.should_welcome == 'true'
102+
uses: marocchino/sticky-pull-request-comment@773744901bac0e8cbb5a0dc842800d45e9b2b405 # v2.9.4
103+
with:
104+
header: 'New Contributor Welcome'
105+
message: |
106+
## Welcome new contributor!
107+
Thank you for contributing to Mathlib! If you haven't done so already, please review our [contribution guidelines](https://leanprover-community.github.io/contribute/index.html), as well as the [style guide](https://leanprover-community.github.io/contribute/style.html) and [naming conventions](https://leanprover-community.github.io/contribute/naming.html).
108+
109+
We use a [review queue](https://leanprover-community.github.io/queueboard/review_dashboard.html) to manage reviews. If your PR does not appear there, it is probably because it is not successfully building (i.e., it doesn't have a green checkmark), has the `awaiting-author` tag, or another reason described in the [Lifecycle of a PR](https://leanprover-community.github.io/contribute/index.html#lifecycle-of-a-pr).
110+
111+
If you haven't already done so, please come to [https://leanprover.zulipchat.com/](https://leanprover.zulipchat.com/), introduce yourself, and mention your new PR.
112+
113+
Thank you again for joining our community.

0 commit comments

Comments
 (0)