File tree Expand file tree Collapse file tree 2 files changed +85
-0
lines changed Expand file tree Collapse file tree 2 files changed +85
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Comment on first contribution
2+
3+ on :
4+ workflow_call :
5+ inputs :
6+ pull_request_message :
7+ description : >
8+ The Markdown message to comment when a contributor creates their first
9+ pull request.
10+ type : string
11+ required : false
12+ issue_message :
13+ description : >
14+ The Markdown message to comment when a contributor creates their first
15+ issue.
16+ type : string
17+ required : false
18+
19+ jobs :
20+ comment :
21+ if : >
22+ (
23+ (github.event_name == 'pull_request_target' && inputs.pull_request_message) ||
24+ (github.event_name == 'issues' && inputs.issue_message)
25+ ) &&
26+ github.event.action == 'opened' &&
27+ contains(
28+ fromJSON('["FIRST_TIMER", "FIRST_TIME_CONTRIBUTOR"]'),
29+ github.event_name == 'issues'
30+ && github.event.issue.author_association
31+ || github.event.pull_request.author_association
32+ )
33+ runs-on : ubuntu-latest
34+ permissions :
35+ issues : write
36+ pull-requests : write
37+ steps :
38+ - uses : actions/github-script@v7
39+ env :
40+ # Pass the message via an environment variable rather than
41+ # interpolating to prevent code injection.
42+ message : >-
43+ ${{
44+ github.event_name == 'issues'
45+ && inputs.issue_message
46+ || inputs.pull_request_message
47+ }}
48+ with :
49+ script : |
50+ await github.rest.issues.createComment({
51+ issue_number: context.issue.number,
52+ owner: context.repo.owner,
53+ repo: context.repo.repo,
54+ body: process.env.message
55+ })
Original file line number Diff line number Diff line change @@ -73,6 +73,36 @@ pre_build_command: "apt-get update -y -q && apt-get install -y -q example"
7373
7474macOS and Windows platform support will be available soon.
7575
76+ # ## Welcome a first-time contributor
77+
78+ This is example of a recommended workflow for creating a comment with the
79+ specified Markdown text when a first-time contributor opens an issue or pull
80+ request :
81+
82+ ` ` ` yaml
83+ name: Comment on first contribution
84+
85+ on:
86+ pull_request_target:
87+ types: [opened]
88+ issues:
89+ types: [opened]
90+
91+ jobs:
92+ comment:
93+ uses: swiftlang/github-workflows/.github/workflows/comment_on_first_contribution.yml@main
94+ with:
95+ pull_request_message: <Markdown message>
96+ issue_message: <Markdown message>
97+ ` ` `
98+
99+ The `pull_request_message` or `issue_message` inputs are optional.
100+ If omitted, comments will not be created on pull requests or issues,
101+ respectively.
102+ If you only want to greet first-time contributors on either pull requests or
103+ issues, adjust the events that cause the workflow to run under the `on` keyword
104+ besides omitting the corresponding input.
105+
76106# # Running workflows locally
77107
78108You can run the Github Actions workflows locally using
You can’t perform that action at this time.
0 commit comments