Skip to content

Commit

Permalink
automated updation of voteTrackingFile.json on removal of a TSC Member
Browse files Browse the repository at this point in the history
  • Loading branch information
kaneki003 committed Dec 22, 2024
1 parent 5a3b493 commit 86fafb0
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 48 deletions.
60 changes: 43 additions & 17 deletions .github/workflows/tsc_management.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
pull_request:
types: [closed]
paths:
- 'MAINTAINERS.yaml'
- "MAINTAINERS.yaml"

jobs:
detect_tsc_membership_changes:
Expand Down Expand Up @@ -50,17 +50,17 @@ jobs:
function hasIsTscMemberChanged(maintainerGithub) {
const mainMaintainer = mainFile.find(m => m.github === maintainerGithub);
const prMaintainer = prFile.find(m => m.github === maintainerGithub);
core.info(`Checking for ${maintainerGithub}`);
if (!mainMaintainer || !prMaintainer) {
console.error('Maintainer not found:', maintainerGithub);
return;
}
core.info(`${maintainerGithub} in mainFile has isTscMember as:`, mainMaintainer.isTscMember);
core.info(`${maintainerGithub} in prFile has isTscMember as:`, prMaintainer.isTscMember);
if (mainMaintainer.isTscMember !== prMaintainer.isTscMember) {
core.info(`isTscMember value changed for ${maintainerGithub}`);
updatedMaintainers.push({ githubUser: maintainerGithub, updatedValue: mainMaintainer.isTscMember });
Expand All @@ -70,15 +70,15 @@ jobs:
// Loop over all maintainers and find the changes
mainFile.forEach(maintainer => hasIsTscMemberChanged(maintainer.github));
// Log final results
core.info("Final updatedValue:", updatedValue);
core.info("Final updatedMaintainers:", JSON.stringify(updatedMaintainers));
// Set outputs
core.setOutput("updatedValue", updatedValue);
core.setOutput("updatedMaintainers", JSON.stringify(updatedMaintainers));
outputs:
outputs:
updatedValue: ${{ steps.compare-files.outputs.updatedValue }}
updatedMaintainers: ${{ steps.compare-files.outputs.updatedMaintainers }}

Expand Down Expand Up @@ -165,6 +165,24 @@ jobs:
core.setFailed(`Failed to remove ${maintainer.githubUser} from the team: ${error.message}`);
}
}
- name: Update voteTrackingFile.json
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GH_TOKEN }}
script: |
const fs = require('fs');
const path = './voteTrackingFile.json';
const removedMaintainers = JSON.parse('${{ needs.detect_tsc_membership_changes.outputs.updatedMaintainers }}');
let voteTrackingData = JSON.parse(fs.readFileSync(path, 'utf8'));
removedMaintainers.forEach(maintainer => {
voteTrackingData = voteTrackingData.filter(vote => vote.name !== maintainer.githubUser);
});
fs.writeFileSync(path, JSON.stringify(voteTrackingData, null, 2));
console.log('Updated voteTrackingFile.json:\n', JSON.stringify(voteTrackingData, null, 2));
outputs:
removedMaintainers: ${{ needs.detect_tsc_membership_changes.outputs.updatedMaintainers }}

Expand Down Expand Up @@ -230,7 +248,7 @@ jobs:
// Log the updated content to the console
console.log('Updated Emeritus.yaml:\n', content);
- name: Create new branch
run: |
git checkout -b update-emeritus-${{ github.run_id }}
Expand All @@ -247,13 +265,21 @@ jobs:
notify_slack_on_failure:
if: always() && (needs.detect_tsc_membership_changes.result == 'failure' || needs.add_tsc_member.result == 'failure' || needs.display_message.result == 'failure' || needs.update_emeritus.result == 'failure' || needs.remove_tsc_member.result == 'failure' || needs.remove_tsc_goodbye.result == 'failure')
needs: [detect_tsc_membership_changes, add_tsc_member, display_message, update_emeritus,remove_tsc_goodbye, remove_tsc_member]
needs:
[
detect_tsc_membership_changes,
add_tsc_member,
display_message,
update_emeritus,
remove_tsc_goodbye,
remove_tsc_member,
]
runs-on: ubuntu-latest
steps:
- name: Report workflow run status to Slack
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{secrets.SLACK_CI_FAIL_NOTIFY}}
SLACK_TITLE: 🚨 TSC Management Workflow failed 🚨
SLACK_MESSAGE: Failed to post a message to new TSC member
MSG_MINIMAL: true
- name: Report workflow run status to Slack
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{secrets.SLACK_CI_FAIL_NOTIFY}}
SLACK_TITLE: 🚨 TSC Management Workflow failed 🚨
SLACK_MESSAGE: Failed to post a message to new TSC member
MSG_MINIMAL: true
60 changes: 30 additions & 30 deletions .github/workflows/vote-verifcation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,44 +21,44 @@ jobs:
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GH_TOKEN_BOT_EVE }}
script : |
const isTSCMember = ${{ steps.verify_member.outputs.isTSCMember}}
if(!isTSCMember) {
const commentText = `Hi @${{ github.actor }}, since you are not a [TSC Member](https://www.asyncapi.com/community/tsc), you cannot start or stop voting. Please [read more about voting process](https://github.com/asyncapi/community/blob/master/voting.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`);
}
script: |
const isTSCMember = ${{ steps.verify_member.outputs.isTSCMember}}
if(!isTSCMember) {
const commentText = `Hi @${{ github.actor }}, since you are not a [TSC Member](https://www.asyncapi.com/community/tsc), you cannot start or stop voting. Please [read more about voting process](https://github.com/asyncapi/community/blob/master/voting.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
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
fi
env:
GH_TOKEN: ${{ secrets.GH_TOKEN_BOT_EVE }}
- 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
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
fi
env:
GH_TOKEN: ${{ secrets.GH_TOKEN_BOT_EVE }}
2 changes: 1 addition & 1 deletion Emeritus.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This file lists individuals who were previously TSC members and Ambassadors but are no longer active.

emeritus_tsc:
- jotamusik
- jotamusik
- LouisXhaferi
- aeworxet
- arjungarg07
Expand Down

0 comments on commit 86fafb0

Please sign in to comment.