File tree 2 files changed +84
-0
lines changed
2 files changed +84
-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
+ steps :
37
+ - uses : actions/github-script@v7
38
+ env :
39
+ # Pass the message via an environment variable rather than
40
+ # interpolating to prevent code injection.
41
+ message : >-
42
+ ${{
43
+ github.event_name == 'issues'
44
+ && inputs.issue_message
45
+ || inputs.pull_request_message
46
+ }}
47
+ with :
48
+ script : |
49
+ await github.rest.issues.createComment({
50
+ issue_number: context.issue.number,
51
+ owner: context.repo.owner,
52
+ repo: context.repo.repo,
53
+ body: process.env.message
54
+ })
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"
73
73
74
74
macOS and Windows platform support will be available soon.
75
75
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
+
76
106
# # Running workflows locally
77
107
78
108
You can run the Github Actions workflows locally using
You can’t perform that action at this time.
0 commit comments