From 86fafb018419677dc456c08762353971c718bf36 Mon Sep 17 00:00:00 2001 From: kaneki003 Date: Sun, 22 Dec 2024 12:25:31 +0530 Subject: [PATCH] automated updation of voteTrackingFile.json on removal of a TSC Member --- .github/workflows/tsc_management.yml | 60 ++++++++++++++++++-------- .github/workflows/vote-verifcation.yml | 60 +++++++++++++------------- Emeritus.yaml | 2 +- 3 files changed, 74 insertions(+), 48 deletions(-) diff --git a/.github/workflows/tsc_management.yml b/.github/workflows/tsc_management.yml index ea51cf729..2ed7b123f 100644 --- a/.github/workflows/tsc_management.yml +++ b/.github/workflows/tsc_management.yml @@ -4,7 +4,7 @@ on: pull_request: types: [closed] paths: - - 'MAINTAINERS.yaml' + - "MAINTAINERS.yaml" jobs: detect_tsc_membership_changes: @@ -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 }); @@ -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 }} @@ -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 }} @@ -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 }} @@ -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 diff --git a/.github/workflows/vote-verifcation.yml b/.github/workflows/vote-verifcation.yml index dfd592b5c..544a0d24a 100644 --- a/.github/workflows/vote-verifcation.yml +++ b/.github/workflows/vote-verifcation.yml @@ -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 }} diff --git a/Emeritus.yaml b/Emeritus.yaml index a21171d8a..fa1190b61 100644 --- a/Emeritus.yaml +++ b/Emeritus.yaml @@ -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