Skip to content

Commit 968f67b

Browse files
committed
tools: add a script to help with nomination
1 parent 1758b74 commit 968f67b

File tree

2 files changed

+86
-0
lines changed

2 files changed

+86
-0
lines changed

GOVERNANCE.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,12 @@ Example of list of contributions:
269269
organization
270270
* Other participation in the wider Node.js community
271271

272+
You can use the ad-hoc script to use `gh` to open the private discussion:
273+
274+
```sh
275+
./tools/actions/nominate.sh GITHUB_ID
276+
```
277+
272278
The nomination passes if no collaborators oppose it (as described in the
273279
following section) after one week. In the case of an objection, the TSC is
274280
responsible for working with the individuals involved and finding a resolution.

tools/actions/nominate.sh

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#!/bin/sh
2+
3+
set -ex
4+
5+
ORG=nodejs
6+
REPO=collaborators
7+
8+
prepare_collaborator_nomination() {
9+
HANDLE="$1"
10+
11+
[ -n "$HANDLE" ] || {
12+
echo "Missing handle" >&2
13+
return 1
14+
}
15+
16+
BODY_FILE=$(mktemp)
17+
cat -> "$BODY_FILE" <<EOF
18+
<!-- Consider writing a small intro on the contributor and their contributions -->
19+
20+
* Commits in the nodejs/node repository: https://github.com/nodejs/node/commits?author=$HANDLE
21+
* Pull requests and issues opened in the nodejs/node repository: https://github.com/nodejs/node/issues?q=author:$HANDLE
22+
* Comments on pull requests and issues in the nodejs/node repository: https://github.com/nodejs/node/issues?q=commenter:$HANDLE
23+
* Reviews on pull requests in the nodejs/node repository: https://github.com/nodejs/node/pulls?q=reviewed-by:$HANDLE
24+
* Pull requests and issues opened throughout the Node.js organization: https://github.com/search?q=author:$HANDLE+org:$ORG
25+
* Comments on pull requests and issues throughout the Node.js organization: https://github.com/search?q=commenter:$HANDLE+org:$ORG
26+
27+
<!-- You can add more item to that lists, such as: -->
28+
<!--
29+
* Help provided to end-users and novice contributors
30+
* Participation in other projects, teams, and working groups of the Node.js
31+
organization
32+
* Other participation in the wider Node.js community
33+
-->
34+
EOF
35+
$EDITOR "$BODY_FILE"
36+
BODY="$(cat "$BODY_FILE")"
37+
rm "$BODY_FILE"
38+
39+
[ -n "$BODY" ] || {
40+
echo "Empty body" >&2
41+
return 1
42+
}
43+
44+
echo "Getting repo ID and discussion category" >&2
45+
REPO_ID_AND_DISCUSSION_CATEGORY_ID="$(gh api graphql -f query='
46+
query($owner:String!,$repo:String!){
47+
repository(owner:$owner,name:$repo){
48+
id
49+
discussionCategories(first:100){
50+
nodes{ id name }
51+
}
52+
}
53+
}' -F owner="$ORG" -F repo="$REPO" --jq '[
54+
.data.repository.id,
55+
(.data.repository.discussionCategories.nodes[] | select(.name=="Collaborator nominations") | .id)
56+
] | @tsv')"
57+
REPO_ID=$(echo "$REPO_ID_AND_DISCUSSION_CATEGORY_ID" | cut -f1)
58+
[ -n "$REPO_ID" ] || {
59+
echo "Cannot find repo ID" >&2
60+
return 1
61+
}
62+
CATEGORY_ID=$(echo "$REPO_ID_AND_DISCUSSION_CATEGORY_ID" | cut -f2)
63+
[ -n "$CATEGORY_ID" ] || {
64+
echo "Missing discussion category ID" >&2
65+
return 1
66+
}
67+
68+
gh api graphql -f query='
69+
mutation($repo: ID!,$cat: ID!,$title: String!,$body: String!){
70+
createDiscussion(input: {
71+
repositoryId: $repo
72+
categoryId: $cat
73+
title: $title
74+
body: $body
75+
}){ discussion { url } }
76+
}' \
77+
-F repo="$REPO_ID" -F cat="$CATEGORY_ID" -F title="Nominating ${HANDLE}?" -F body="$BODY"
78+
}
79+
80+
prepare_collaborator_nomination "$1"

0 commit comments

Comments
 (0)