Skip to content

Commit

Permalink
Add workflow to enable voting
Browse files Browse the repository at this point in the history
  • Loading branch information
AayushSaini101 committed Mar 24, 2024
1 parent 7c1e69a commit 5b0c743
Show file tree
Hide file tree
Showing 3 changed files with 195 additions and 0 deletions.
70 changes: 70 additions & 0 deletions .github/workflows/add_vote_label.yml
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';
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, '/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 }}

71 changes: 71 additions & 0 deletions .github/workflows/remove_vote_label.yml
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 }}

54 changes: 54 additions & 0 deletions .gitvote.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
profiles:
default:
duration: 2m
pass_threshold: 51
periodic_status_check: "1 week"
allowed_voters:
teams:
- tsc_members
users:
- 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

0 comments on commit 5b0c743

Please sign in to comment.