-
-
Notifications
You must be signed in to change notification settings - Fork 110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ci: add workflow to enable voting #1120
Changes from 1 commit
5b0c743
04c7047
2aa27ae
b5b28f6
d35401b
603a058
75a665f
bca1c04
d7e79fd
1be2132
bb074f5
eba881f
bc617e2
7c94980
369ac9a
ea9aeb8
e8443d0
b1ab7da
dd1fd13
8102647
ba2a965
3c618ba
7543ccc
28a66fe
494ac73
e93b988
c859699
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
name: Add label to PR on comment | ||
|
||
on: | ||
issue_comment: | ||
types: [created] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Get the comment body | ||
id: get_comment_body | ||
run: | | ||
echo "Comment body: ${{ github.event.comment.body }}" | ls | ||
|
||
- name: Verify TSC Member | ||
id: verify_member | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
const fs = require('fs'); | ||
const filePath = 'TSC_MEMBERS.json'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wrong file, your source of truth is https://github.com/asyncapi/community/blob/master/MAINTAINERS.yaml and entries with also when you will be refactoring your code, please do not use old callbacks but do modern code with async/await There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed thanks @derberg |
||
const commenterName = context.payload.sender.login; | ||
let isTSCMember = false; | ||
|
||
function readFileAndProcess(callback) { | ||
fs.readFile(filePath, 'utf8', (err, data) => { | ||
if (err) { | ||
callback(err, null); | ||
return; | ||
} | ||
try { | ||
const jsonData = JSON.parse(data); | ||
// Iterate over each object in the array | ||
jsonData.forEach(item => { | ||
if (item.github === commenterName) { | ||
isTSCMember = true; | ||
} | ||
}); | ||
// Invoke the callback function with the result | ||
callback(null, isTSCMember); | ||
} catch (parseError) { | ||
callback(parseError, null); | ||
} | ||
}); | ||
} | ||
|
||
readFileAndProcess((error, result) => { | ||
if (error) { | ||
console.error('Error:', error); | ||
} else { | ||
console.log('Is TSC Member:', result); | ||
core.setOutput('isTSCMember', isTSCMember); | ||
} | ||
}); | ||
|
||
- name: Add the label | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we also need a step that will post a comment back in case not TSC member added here you have example how to do it: https://github.com/asyncapi/.github/blob/master/.github/workflows/bounty-program-commands.yml#L33 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @derberg when we allowed only TSC members voting, this will be double check, The user will be filter out when the it is not matching with the authorised voters, this will be message. AayushSaini101/Vote#15 (comment) Which is not a proper message by a gitvote-bot, we can allow voting for all contributors, then we can provide the custom comment not default one, This would be the best way to describe the situation in comments, instead of using default comments of the particular vote, What do you think ? @derberg There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The representation of the templates of the gitvote is not proper for unauthorised vote https://github.com/cncf/gitvote/tree/main/templates, We can modify easily and make proper by changing own workflow as you shared in this https://github.com/asyncapi/.github/blob/master/.github/workflows/bounty-program-commands.yml#L33 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh yeah, if git vote bot does the verification for us, then we should use it and not do it on our own as we will the over communicate, duplicate it kinda There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We cannot test the /vote command in the individual account need to use in the community, Reference cncf/gitvote#480
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
if: contains(github.event.comment.body, '/vote') && steps.verify_member.outputs.isTSCMember =='true' | ||
run: | ||
if [ "${{ github.event_name }}" = "pull_request" ]; then | ||
gh pr edit ${{ github.event.pull_request.number }} --add-label "vote" | ||
else | ||
gh issue edit ${{ github.event.issue.number }} --add-label "vote" | ||
fi | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
name: Remove vote label | ||
|
||
on: | ||
issue_comment: | ||
types: [created] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Get the comment body | ||
id: get_comment_body | ||
run: | | ||
echo "Comment body: ${{ github.event.comment.body }}" | ||
|
||
- name: Verify TSC Member | ||
id: verify_member | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
const fs = require('fs'); | ||
const filePath = 'TSC_MEMBERS.json'; | ||
const commenterName = context.payload.sender.login; | ||
let isTSCMember = false; | ||
|
||
function readFileAndProcess(callback) { | ||
fs.readFile(filePath, 'utf8', (err, data) => { | ||
if (err) { | ||
callback(err, null); | ||
return; | ||
} | ||
try { | ||
const jsonData = JSON.parse(data); | ||
// Iterate over each object in the array | ||
jsonData.forEach(item => { | ||
if (item.github === commenterName) { | ||
isTSCMember = true; | ||
} | ||
}); | ||
// Invoke the callback function with the result | ||
callback(null, isTSCMember); | ||
} catch (parseError) { | ||
callback(parseError, null); | ||
} | ||
}); | ||
} | ||
|
||
readFileAndProcess((error, result) => { | ||
if (error) { | ||
console.error('Error:', error); | ||
} else { | ||
console.log('Is TSC Member:', result); | ||
core.setOutput('isTSCMember', isTSCMember); | ||
} | ||
}); | ||
|
||
- name: Add the label | ||
if: contains(github.event.comment.body, '/cancel-vote') && steps.verify_member.outputs.isTSCMember =='true' | ||
run: | ||
run:| | ||
if [ "${{ github.event_name }}" = "pull_request" ]; then | ||
gh pr edit ${{ github.event.pull_request.number }} --remove-label "vote" | ||
else | ||
gh issue edit ${{ github.event.issue.number }} --remove-label "vote" | ||
fi | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
profiles: | ||
derberg marked this conversation as resolved.
Show resolved
Hide resolved
|
||
default: | ||
duration: 2m | ||
AayushSaini101 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
pass_threshold: 51 | ||
periodic_status_check: "1 week" | ||
AayushSaini101 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
allowed_voters: | ||
teams: | ||
- tsc_members | ||
users: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. all of them should be in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added new yaml file |
||
- aayushmau5 | ||
- imabp | ||
- akshatnema | ||
- anandsunderraman | ||
- arjungarg07 | ||
- CameronRushton | ||
- dalelane | ||
- emilianozublena | ||
- fmvilas | ||
- GeraldLoeffler | ||
- jonaslagoni | ||
- KhudaDad414 | ||
- lbroudoux | ||
- m3lkior | ||
- derberg | ||
- magicmatatjahu | ||
- AceTheCreator | ||
- damaru-inc | ||
- mcturco | ||
- NektariosFifes | ||
- Pakisan | ||
- theschles | ||
- pratik2315 | ||
- rcoppen | ||
- smoya | ||
- Souvikns | ||
- alequetzalli | ||
- BOLT04 | ||
- dan-r | ||
- KieranM1999 | ||
- JEFFLUFC | ||
- thulieblack | ||
- lewis-relph | ||
- boyney123 | ||
- Tenischev | ||
- Samridhi-98 | ||
- ron-debajyoti | ||
- ivangsa | ||
- Florence-Njeri | ||
- whitlockjc | ||
- char0n | ||
- VisualBean | ||
- Barbanio | ||
- kennethaasan | ||
- GreenRover |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed @derberg thanks