-
-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: add workflow to enable voting (#1120)
- Loading branch information
1 parent
94db865
commit bc65cc3
Showing
3 changed files
with
118 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: Verify Member | ||
outputs: | ||
isTSCMember: | ||
description: 'Check whether the person is TSCMember or not' | ||
value: ${{steps.verify_member.outputs.isTSCMember}} | ||
inputs: | ||
authorName: | ||
description: 'Name of the commentor' | ||
required: true | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install the dependencies | ||
run: npm install [email protected] | ||
shell: bash | ||
|
||
- name: Verify TSC Member | ||
id: verify_member | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
const yaml = require('js-yaml'); | ||
const fs = require('fs'); | ||
const commenterName = '${{ inputs.authorName }}'; | ||
let isTSCMember = false; | ||
try { | ||
// Load YAML file | ||
const data = yaml.load(fs.readFileSync('MAINTAINERS.yaml', 'utf8')); | ||
// Filter persons who are TSC members and whose GitHub username matches commenterName | ||
const isTscMember = data.find(person => { | ||
return (person.isTscMember === true || person.isTscMember === "true") && person.github === commenterName; | ||
}); | ||
// Check if a TSC member was found | ||
if (isTscMember) { | ||
isTSCMember = true; | ||
} | ||
|
||
core.setOutput('isTSCMember', isTSCMember); | ||
} catch (e) { | ||
console.log(e); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
name: Verification of the Vote | ||
|
||
on: | ||
issue_comment: | ||
types: [created] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Verify the person | ||
id: verify_member | ||
uses: ./.github/actions/verifyTSCMember | ||
with: | ||
authorName: "${{github.event.comment.user.login}}" | ||
|
||
- name: Checking the person authenticity. | ||
if: contains(github.event.comment.body, '/vote') || contains(github.event.comment.body, '/cancel-vote') | ||
uses: actions/github-script@v6 | ||
with: | ||
script : | | ||
const isTSCMember = ${{ steps.verify_member.outputs.isTSCMember}} | ||
if(!isTSCMember) { | ||
const commentText = `User ❌ @${{ github.actor }} is not a [TSC Member](https://www.asyncapi.com/community/tsc). Learn more from [guidelines to become a TSC Member](https://github.com/asyncapi/community/blob/master/TSC_MEMBERSHIP.md)`; | ||
console.log(`User ❌ @${{ github.actor }} is not a TSC Member`); | ||
github.rest.issues.createComment({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: commentText | ||
}); | ||
} else if('${{github.actor}}' != 'git-vote[bot]') { | ||
console.log(`User ✅ @${{ github.actor }} is a TSC Member`); | ||
} | ||
- name: Add the label | ||
run: | | ||
if [ "${{steps.verify_member.outputs.isTSCMember}}" == "true" ]; then | ||
if [ "${{ github.event.comment.body }}" == "/vote" ]; then | ||
if [ "${{ github.event_name }}" != "pull_request" ]; then | ||
gh issue edit ${{ github.event.issue.number }} --add-label "vote" | ||
else | ||
gh pr edit ${{ github.event.issue.number }} --add-label "vote" | ||
fi | ||
fi | ||
fi | ||
env: | ||
GH_TOKEN: ${{ github.token }} | ||
- name: Remove the label | ||
run: | | ||
if [ "${{steps.verify_member.outputs.isTSCMember}}" == "true" ]; then | ||
if [ "${{ github.event.comment.body }}" == "/cancel-vote" ]; then | ||
if [ "${{ github.event_name }}" != "pull_request" ]; then | ||
gh issue edit ${{ github.event.issue.number }} --remove-label "vote" | ||
else | ||
gh pr edit ${{ github.event.issue.number }} --remove-label "vote" | ||
fi | ||
fi | ||
fi | ||
env: | ||
GH_TOKEN: ${{ github.token }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
profiles: | ||
default: | ||
duration: 4w | ||
pass_threshold: 51 | ||
periodic_status_check: "1 week" | ||
close_on_passing: true | ||
allowed_voters: | ||
teams: | ||
- tsc_members |