From 4a0f92169234a48ea1c787322bc96872c4ab82de Mon Sep 17 00:00:00 2001 From: 14Richa Date: Fri, 21 Jul 2023 15:25:06 +0530 Subject: [PATCH 01/22] added new workflow regarding update tsc teams --- .github/workflows/update-tsc.yml | 69 ++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 .github/workflows/update-tsc.yml diff --git a/.github/workflows/update-tsc.yml b/.github/workflows/update-tsc.yml new file mode 100644 index 000000000..2eefb92a5 --- /dev/null +++ b/.github/workflows/update-tsc.yml @@ -0,0 +1,69 @@ +name: TSC Member Update + +on: + pull_request: + types: [closed] + +jobs: + update_tsc_member: + if: github.event.pull_request.merged + name: Update TSC Member + runs-on: ubuntu-latest + + steps: + - name: Checkout main branch + uses: actions/checkout@v2 + with: + ref: master + path: community-main + + - name: Checkout one commit before last one + uses: actions/checkout@v2 + with: + fetch-depth: 2 + ref: master + path: community + + - run: cd community && git checkout HEAD^ + + - name: Install js-yaml + run: npm install js-yaml@4.1.0 + + - name: Compare files + id: compare-files + uses: actions/github-script@v6 + with: + script: | + const fs = require('fs'); + const yaml = require('js-yaml'); + + const mainFile = yaml.load(fs.readFileSync('./community-main/MAINTAINERS.yaml', 'utf8')); + const prFile = yaml.load(fs.readFileSync('./community/MAINTAINERS.yaml', 'utf8')); + + // Variables to store the updated value and GitHub user + let updatedMaintainers = []; + let updatedValue; + + // Function to check if isTscMember value has changed + function hasIsTscMemberChanged(maintainerGithub) { + const mainMaintainer = mainFile.find(m => m.github === maintainerGithub); + const prMaintainer = prFile.find(m => m.github === maintainerGithub); + + if (!mainMaintainer || !prMaintainer) { + console.error('Maintainer not found:', maintainerGithub); + return; + } + + if (mainMaintainer.isTscMember !== prMaintainer.isTscMember) { + console.log(`isTscMember value changed for ${maintainerGithub}`); + updatedMaintainers.push({ githubUser: maintainerGithub, updatedValue: prMaintainer.isTscMember }); + updatedValue = prMaintainer.isTscMember; + } + } + + // Loop over all maintainers and find the changes + mainFile.forEach(maintainer => hasIsTscMemberChanged(maintainer.github)); + + // Set outputs + core.setOutput("updatedValue", updatedValue); + core.setOutput("updatedMaintainers", JSON.stringify(updatedMaintainers)); \ No newline at end of file From 3abeeb6731cd5861a816c534d2be304ef62e4c82 Mon Sep 17 00:00:00 2001 From: 14Richa Date: Mon, 24 Jul 2023 12:55:37 +0530 Subject: [PATCH 02/22] added new job --- .github/workflows/update-tsc.yml | 67 +++++++++++++++++++++++++------- 1 file changed, 52 insertions(+), 15 deletions(-) diff --git a/.github/workflows/update-tsc.yml b/.github/workflows/update-tsc.yml index 2eefb92a5..57507cea1 100644 --- a/.github/workflows/update-tsc.yml +++ b/.github/workflows/update-tsc.yml @@ -46,24 +46,61 @@ jobs: // Function to check if isTscMember value has changed function hasIsTscMemberChanged(maintainerGithub) { - const mainMaintainer = mainFile.find(m => m.github === maintainerGithub); - const prMaintainer = prFile.find(m => m.github === maintainerGithub); - - if (!mainMaintainer || !prMaintainer) { - console.error('Maintainer not found:', maintainerGithub); - return; - } - - if (mainMaintainer.isTscMember !== prMaintainer.isTscMember) { - console.log(`isTscMember value changed for ${maintainerGithub}`); - updatedMaintainers.push({ githubUser: maintainerGithub, updatedValue: prMaintainer.isTscMember }); - updatedValue = prMaintainer.isTscMember; - } + const mainMaintainer = mainFile.find(m => m.github === maintainerGithub); + const prMaintainer = prFile.find(m => m.github === maintainerGithub); + + console.log(`Checking for ${maintainerGithub}`); + + if (!mainMaintainer || !prMaintainer) { + console.error('Maintainer not found:', maintainerGithub); + return; + } + + console.log(`${maintainerGithub} in mainFile has isTscMember as:`, mainMaintainer.isTscMember); + console.log(`${maintainerGithub} in prFile has isTscMember as:`, prMaintainer.isTscMember); + + if (mainMaintainer.isTscMember !== prMaintainer.isTscMember) { + console.log(`isTscMember value changed for ${maintainerGithub}`); + updatedMaintainers.push({ githubUser: maintainerGithub, updatedValue: mainMaintainer.isTscMember }); + updatedValue = mainMaintainer.isTscMember; + } } // Loop over all maintainers and find the changes mainFile.forEach(maintainer => hasIsTscMemberChanged(maintainer.github)); - + + // Log final results + console.log("Final updatedValue:", updatedValue); + console.log("Final updatedMaintainers:", JSON.stringify(updatedMaintainers)); + // Set outputs core.setOutput("updatedValue", updatedValue); - core.setOutput("updatedMaintainers", JSON.stringify(updatedMaintainers)); \ No newline at end of file + core.setOutput("updatedMaintainers", JSON.stringify(updatedMaintainers)); + outputs: + updatedValue: ${{ steps.compare-files.outputs.updatedValue }} + updatedMaintainers: ${{ steps.compare-files.outputs.updatedMaintainers }} + + add_to_tsc_members_team: + needs: update_tsc_member + if: needs.update_tsc_member.outputs.updatedValue + runs-on: ubuntu-latest + + steps: + - name: Add new maintainers to the team + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.BOT_TOKEN }} + script: | + const updatedMaintainers = JSON.parse('${{ needs.update_tsc_member.outputs.updatedMaintainers }}'); + for (const maintainerObj of updatedMaintainers) { + const maintainer = maintainerObj.githubUser; + try { + await github.request('PUT /orgs/{org}/teams/{team_slug}/memberships/{username}', { + org: 'asyncapi', + team_slug: 'tsc_members', + username: tsc_members + }); + } catch (error) { + console.error(`Failed to add ${maintainer} to the team:`, error); + } + } \ No newline at end of file From 7a6f06d84016373f99f5ce2ca6b4f34795349e81 Mon Sep 17 00:00:00 2001 From: 14Richa Date: Mon, 24 Jul 2023 13:13:14 +0530 Subject: [PATCH 03/22] added path arg --- .github/workflows/update-tsc.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/update-tsc.yml b/.github/workflows/update-tsc.yml index 57507cea1..28914b92a 100644 --- a/.github/workflows/update-tsc.yml +++ b/.github/workflows/update-tsc.yml @@ -3,6 +3,8 @@ name: TSC Member Update on: pull_request: types: [closed] + paths: + - 'MAINTAINERS.yaml' jobs: update_tsc_member: From e2dc6b991d9941e568c31799732450f5a72a53d2 Mon Sep 17 00:00:00 2001 From: 14Richa Date: Tue, 25 Jul 2023 14:02:08 +0530 Subject: [PATCH 04/22] minor fix --- .github/workflows/update-tsc.yml | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/.github/workflows/update-tsc.yml b/.github/workflows/update-tsc.yml index 28914b92a..08da41451 100644 --- a/.github/workflows/update-tsc.yml +++ b/.github/workflows/update-tsc.yml @@ -51,18 +51,18 @@ jobs: const mainMaintainer = mainFile.find(m => m.github === maintainerGithub); const prMaintainer = prFile.find(m => m.github === maintainerGithub); - console.log(`Checking for ${maintainerGithub}`); + core.info(`Checking for ${maintainerGithub}`); if (!mainMaintainer || !prMaintainer) { console.error('Maintainer not found:', maintainerGithub); return; } - console.log(`${maintainerGithub} in mainFile has isTscMember as:`, mainMaintainer.isTscMember); - console.log(`${maintainerGithub} in prFile has isTscMember as:`, prMaintainer.isTscMember); + 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) { - console.log(`isTscMember value changed for ${maintainerGithub}`); + core.info(`isTscMember value changed for ${maintainerGithub}`); updatedMaintainers.push({ githubUser: maintainerGithub, updatedValue: mainMaintainer.isTscMember }); updatedValue = mainMaintainer.isTscMember; } @@ -72,8 +72,8 @@ jobs: mainFile.forEach(maintainer => hasIsTscMemberChanged(maintainer.github)); // Log final results - console.log("Final updatedValue:", updatedValue); - console.log("Final updatedMaintainers:", JSON.stringify(updatedMaintainers)); + core.info("Final updatedValue:", updatedValue); + core.info("Final updatedMaintainers:", JSON.stringify(updatedMaintainers)); // Set outputs core.setOutput("updatedValue", updatedValue); @@ -82,7 +82,7 @@ jobs: updatedValue: ${{ steps.compare-files.outputs.updatedValue }} updatedMaintainers: ${{ steps.compare-files.outputs.updatedMaintainers }} - add_to_tsc_members_team: + add_to_tsc_members_team: needs: update_tsc_member if: needs.update_tsc_member.outputs.updatedValue runs-on: ubuntu-latest @@ -97,12 +97,8 @@ jobs: for (const maintainerObj of updatedMaintainers) { const maintainer = maintainerObj.githubUser; try { - await github.request('PUT /orgs/{org}/teams/{team_slug}/memberships/{username}', { - org: 'asyncapi', - team_slug: 'tsc_members', - username: tsc_members - }); + await github.request(`PUT /orgs/asyncapi/teams/tsc_members/memberships/${maintainer}`); } catch (error) { - console.error(`Failed to add ${maintainer} to the team:`, error); + core.setFailed(`Failed to add ${maintainer} to the team: ${error.message}`); } } \ No newline at end of file From b9ff78d58f29ee38f0af7a8ba222870076fb0848 Mon Sep 17 00:00:00 2001 From: 14Richa Date: Wed, 26 Jul 2023 12:30:46 +0530 Subject: [PATCH 05/22] changed token name --- .github/workflows/update-tsc.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-tsc.yml b/.github/workflows/update-tsc.yml index 08da41451..25d6fb283 100644 --- a/.github/workflows/update-tsc.yml +++ b/.github/workflows/update-tsc.yml @@ -91,7 +91,7 @@ jobs: - name: Add new maintainers to the team uses: actions/github-script@v6 with: - github-token: ${{ secrets.BOT_TOKEN }} + github-token: ${{ secrets.GH_TOKEN }} script: | const updatedMaintainers = JSON.parse('${{ needs.update_tsc_member.outputs.updatedMaintainers }}'); for (const maintainerObj of updatedMaintainers) { From 3a0aec650b4921ba84d8ddbb2f25394233d18b2c Mon Sep 17 00:00:00 2001 From: 14Richa Date: Wed, 26 Jul 2023 15:37:31 +0530 Subject: [PATCH 06/22] refactored update tsc workflow --- .github/workflows/update-tsc.yml | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/.github/workflows/update-tsc.yml b/.github/workflows/update-tsc.yml index 25d6fb283..fdc6de656 100644 --- a/.github/workflows/update-tsc.yml +++ b/.github/workflows/update-tsc.yml @@ -82,23 +82,35 @@ jobs: updatedValue: ${{ steps.compare-files.outputs.updatedValue }} updatedMaintainers: ${{ steps.compare-files.outputs.updatedMaintainers }} - add_to_tsc_members_team: + add_or_remove_tsc_members_team: needs: update_tsc_member - if: needs.update_tsc_member.outputs.updatedValue runs-on: ubuntu-latest steps: - - name: Add new maintainers to the team + - name: Add or remove maintainers from the team uses: actions/github-script@v6 with: github-token: ${{ secrets.GH_TOKEN }} script: | + const updatedValue = ${{ needs.update_tsc_member.outputs.updatedValue }}; const updatedMaintainers = JSON.parse('${{ needs.update_tsc_member.outputs.updatedMaintainers }}'); for (const maintainerObj of updatedMaintainers) { const maintainer = maintainerObj.githubUser; try { - await github.request(`PUT /orgs/asyncapi/teams/tsc_members/memberships/${maintainer}`); + if (updatedValue) { + // Add maintainer to the team + await github.request('PUT /orgs/asyncapi/teams/tsc_members/memberships/{username}', { + username: maintainer + }); + core.info(`Successfully added ${maintainer} to the team.`); + } else { + // Remove maintainer from the team + await github.request('DELETE /orgs/asyncapi/teams/tsc_members/memberships/{username}', { + username: maintainer + }); + core.info(`Successfully removed ${maintainer} from the team.`); + } } catch (error) { - core.setFailed(`Failed to add ${maintainer} to the team: ${error.message}`); + core.error(`Failed to update ${maintainer} in the team: ${error.message}`); } } \ No newline at end of file From 07cefd1e9c998e3cd4625f4fae35acf60ed777ef Mon Sep 17 00:00:00 2001 From: 14Richa Date: Thu, 27 Jul 2023 20:08:45 +0530 Subject: [PATCH 07/22] minor fixes in workflow and file name --- .github/workflows/{update-tsc.yml => tsc_management.yml} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename .github/workflows/{update-tsc.yml => tsc_management.yml} (99%) diff --git a/.github/workflows/update-tsc.yml b/.github/workflows/tsc_management.yml similarity index 99% rename from .github/workflows/update-tsc.yml rename to .github/workflows/tsc_management.yml index fdc6de656..01931cf73 100644 --- a/.github/workflows/update-tsc.yml +++ b/.github/workflows/tsc_management.yml @@ -1,4 +1,4 @@ -name: TSC Member Update +name: TSC Management Workflow on: pull_request: From 9eac4d3dad597cf9d439fc8f7a2ce6f590e77823 Mon Sep 17 00:00:00 2001 From: 14Richa Date: Thu, 27 Jul 2023 20:10:32 +0530 Subject: [PATCH 08/22] changed the name of job --- .github/workflows/tsc_management.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tsc_management.yml b/.github/workflows/tsc_management.yml index 01931cf73..86ebb12de 100644 --- a/.github/workflows/tsc_management.yml +++ b/.github/workflows/tsc_management.yml @@ -7,7 +7,7 @@ on: - 'MAINTAINERS.yaml' jobs: - update_tsc_member: + detect_tsc_changes: if: github.event.pull_request.merged name: Update TSC Member runs-on: ubuntu-latest @@ -83,7 +83,7 @@ jobs: updatedMaintainers: ${{ steps.compare-files.outputs.updatedMaintainers }} add_or_remove_tsc_members_team: - needs: update_tsc_member + needs: detect_tsc_changes runs-on: ubuntu-latest steps: @@ -92,8 +92,8 @@ jobs: with: github-token: ${{ secrets.GH_TOKEN }} script: | - const updatedValue = ${{ needs.update_tsc_member.outputs.updatedValue }}; - const updatedMaintainers = JSON.parse('${{ needs.update_tsc_member.outputs.updatedMaintainers }}'); + const updatedValue = ${{ needs.detect_tsc_changes.outputs.updatedValue }}; + const updatedMaintainers = JSON.parse('${{ needs.detect_tsc_changes.outputs.updatedMaintainers }}'); for (const maintainerObj of updatedMaintainers) { const maintainer = maintainerObj.githubUser; try { From 30b3de754f24d240b91d3fce82c64763b1b5a2de Mon Sep 17 00:00:00 2001 From: 14Richa Date: Thu, 27 Jul 2023 21:45:54 +0530 Subject: [PATCH 09/22] added new job --- .github/workflows/tsc_management.yml | 42 +++++++++++++--------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/.github/workflows/tsc_management.yml b/.github/workflows/tsc_management.yml index 86ebb12de..c5fac5e69 100644 --- a/.github/workflows/tsc_management.yml +++ b/.github/workflows/tsc_management.yml @@ -82,35 +82,31 @@ jobs: updatedValue: ${{ steps.compare-files.outputs.updatedValue }} updatedMaintainers: ${{ steps.compare-files.outputs.updatedMaintainers }} - add_or_remove_tsc_members_team: + add_tsc_member: needs: detect_tsc_changes + if: needs.detect_tsc_changes.outputs.updatedValue == 'true' runs-on: ubuntu-latest - steps: - - name: Add or remove maintainers from the team + - name: Add new TSC members to the team uses: actions/github-script@v6 with: - github-token: ${{ secrets.GH_TOKEN }} + github-token: ${{ secrets.BOT_TOKEN }} script: | - const updatedValue = ${{ needs.detect_tsc_changes.outputs.updatedValue }}; - const updatedMaintainers = JSON.parse('${{ needs.detect_tsc_changes.outputs.updatedMaintainers }}'); - for (const maintainerObj of updatedMaintainers) { - const maintainer = maintainerObj.githubUser; - try { - if (updatedValue) { - // Add maintainer to the team - await github.request('PUT /orgs/asyncapi/teams/tsc_members/memberships/{username}', { - username: maintainer - }); - core.info(`Successfully added ${maintainer} to the team.`); - } else { - // Remove maintainer from the team - await github.request('DELETE /orgs/asyncapi/teams/tsc_members/memberships/{username}', { - username: maintainer + async function addTscMembers() { // Wrap the script in an asynchronous function + const newTscMembers = '${{ needs.detect_tsc_changes.outputs.updatedMaintainers }}'.split(','); + for (const tscMember of newTscMembers) { + try { + await github.request('PUT /orgs/{org}/teams/{team_slug}/memberships/{username}', { + org: 'richaOrg', + team_slug: 'maintainers', + username: tscMember }); - core.info(`Successfully removed ${maintainer} from the team.`); + } catch (error) { + console.error(`Failed to add ${tscMember} to the team:`, error); } - } catch (error) { - core.error(`Failed to update ${maintainer} in the team: ${error.message}`); } - } \ No newline at end of file + } + + addTscMembers(); + outputs: + newTscMember: ${{ needs.detect_tsc_changes.outputs.updatedMaintainers }} \ No newline at end of file From 7f1fbbf549b71dcb0482ef0ebefeec748953b025 Mon Sep 17 00:00:00 2001 From: 14Richa Date: Thu, 27 Jul 2023 21:46:18 +0530 Subject: [PATCH 10/22] minor fix --- .github/workflows/tsc_management.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tsc_management.yml b/.github/workflows/tsc_management.yml index c5fac5e69..43a8d515e 100644 --- a/.github/workflows/tsc_management.yml +++ b/.github/workflows/tsc_management.yml @@ -92,7 +92,7 @@ jobs: with: github-token: ${{ secrets.BOT_TOKEN }} script: | - async function addTscMembers() { // Wrap the script in an asynchronous function + async function addTscMembers() { const newTscMembers = '${{ needs.detect_tsc_changes.outputs.updatedMaintainers }}'.split(','); for (const tscMember of newTscMembers) { try { From 260ecfa7244b536d548bc7ca1ad6c6569bd7739e Mon Sep 17 00:00:00 2001 From: 14Richa Date: Thu, 27 Jul 2023 21:47:26 +0530 Subject: [PATCH 11/22] minor fix --- .github/workflows/tsc_management.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tsc_management.yml b/.github/workflows/tsc_management.yml index 43a8d515e..517791e39 100644 --- a/.github/workflows/tsc_management.yml +++ b/.github/workflows/tsc_management.yml @@ -90,15 +90,15 @@ jobs: - name: Add new TSC members to the team uses: actions/github-script@v6 with: - github-token: ${{ secrets.BOT_TOKEN }} + github-token: ${{ secrets.GH_TOKEN }} script: | async function addTscMembers() { const newTscMembers = '${{ needs.detect_tsc_changes.outputs.updatedMaintainers }}'.split(','); for (const tscMember of newTscMembers) { try { await github.request('PUT /orgs/{org}/teams/{team_slug}/memberships/{username}', { - org: 'richaOrg', - team_slug: 'maintainers', + org: 'asyncapi', + team_slug: 'tsc_members', username: tscMember }); } catch (error) { From dbf03bffaa39b7ff047e73cb3d8739ae40db7b90 Mon Sep 17 00:00:00 2001 From: 14Richa Date: Sat, 29 Jul 2023 15:59:30 +0530 Subject: [PATCH 12/22] added new job in tsc management --- .github/workflows/tsc_management.yml | 75 +++++++++++++++++++++++++++- 1 file changed, 74 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tsc_management.yml b/.github/workflows/tsc_management.yml index 517791e39..e337f1058 100644 --- a/.github/workflows/tsc_management.yml +++ b/.github/workflows/tsc_management.yml @@ -109,4 +109,77 @@ jobs: addTscMembers(); outputs: - newTscMember: ${{ needs.detect_tsc_changes.outputs.updatedMaintainers }} \ No newline at end of file + newTscMember: ${{ needs.detect_tsc_changes.outputs.updatedMaintainers }} + + display_message: + needs: add_tsc_member + if: needs.add_tsc_member.outputs.newTscMember != '' + runs-on: ubuntu-latest + steps: + - name: Filter GitHub users with updatedValue + id: filter_users + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.GH_TOKEN }} + script: | + const newTscMembers = JSON.parse('${{ needs.add_tsc_member.outputs.newTscMember }}'); + const filteredUsers = newTscMembers.filter(user => user.updatedValue === true).map(user => user.githubUser); + core.setOutput('filteredUsers', JSON.stringify(filteredUsers)); + + - name: Display welcome message to new TSC members + if: steps.filter_users.outputs.filteredUsers != '[]' + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.GH_TOKEN }} + script: | + const newTscMembers = ${{ steps.filter_users.outputs.filteredUsers }}; + console.log(`New TSC members: ${newTscMembers}`); + const welcomeMessage = newTscMembers.map(tscMember => { + return `@${tscMember.trim().replace(/^@/, '')} Welcome to the AsyncAPI Initiative's TSC Teams! + We value your expertise and look forward to collaborating with you. Feel free to engage in discussions and share your ideas with the TSC. + If you have any questions, reach out on Slack or comment on this pull request. + Congratulations, and let's make great things happen together!` + }).join('\n\n'); + + const { owner, repo } = context.repo; + const { number: issue_number } = context.issue; + github.rest.issues.createComment({ owner, repo, issue_number, body: welcomeMessage }); + + update_emeritus: + needs: add_tsc_member + if: needs.add_tsc_member.outputs.newTscMember != '' + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v2 + + - name: Add TSC members to Emeritus.yaml and print + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.GH_TOKEN }} + script: | + const fs = require('fs'); + const path = './Emeritus.yaml'; + + // Read the current content of the file + let content = fs.readFileSync(path, 'utf8').trim(); // remove any trailing whitespaces + + // Parse the updatedMaintainers JSON string to an array of objects + const updatedMaintainers = JSON.parse('${{ needs.add_tsc_member.outputs.newTscMember }}'); + + // Filter the maintainers whose updatedValue is true and prepare them for the yaml format + const addedTscMembers = updatedMaintainers + .filter(maintainer => maintainer.updatedValue === true) + .map(maintainer => ` - ${maintainer.githubUser.trim()}`) + .join('\n'); + + // Append the added maintainers to the file content + if (addedTscMembers) { + content = content + '\n' + addedTscMembers; + } + + // Write the updated content back to the file + fs.writeFileSync(path, content); + + // Log the updated content to the console + console.log('Updated Emeritus.yaml:\n', content); \ No newline at end of file From 7415bdab7c8037ac196b8a6d8ce8a368ac8a502d Mon Sep 17 00:00:00 2001 From: 14Richa Date: Sat, 29 Jul 2023 16:01:40 +0530 Subject: [PATCH 13/22] added new steps --- .github/workflows/tsc_management.yml | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tsc_management.yml b/.github/workflows/tsc_management.yml index e337f1058..c534743fc 100644 --- a/.github/workflows/tsc_management.yml +++ b/.github/workflows/tsc_management.yml @@ -182,4 +182,18 @@ jobs: fs.writeFileSync(path, content); // Log the updated content to the console - console.log('Updated Emeritus.yaml:\n', content); \ No newline at end of file + console.log('Updated Emeritus.yaml:\n', content); + + - name: Create new branch + run: | + git checkout -b update-emeritus-${{ github.run_id }} + + - name: Commit and push + run: | + git add . + git commit -m "Update Emeritus.yaml" + git push https://${{ secrets.GH_TOKEN}}@github.com/asyncapi/community update-emeritus-${{ github.run_id }} + + - name: Create PR + run: | + gh pr create --title "docs(community): update latest emeritus list" --body "Updated Emeritus list is available and this PR introduces changes with latest information about Emeritus" --head update-emeritus-${{ github.run_id }} \ No newline at end of file From bd06ccc7420fbbae865b322eafbfe0a7e386baa3 Mon Sep 17 00:00:00 2001 From: 14Richa Date: Sat, 29 Jul 2023 16:45:22 +0530 Subject: [PATCH 14/22] added job refactored --- .github/workflows/tsc_management.yml | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/.github/workflows/tsc_management.yml b/.github/workflows/tsc_management.yml index c534743fc..9b5315429 100644 --- a/.github/workflows/tsc_management.yml +++ b/.github/workflows/tsc_management.yml @@ -92,22 +92,17 @@ jobs: with: github-token: ${{ secrets.GH_TOKEN }} script: | - async function addTscMembers() { - const newTscMembers = '${{ needs.detect_tsc_changes.outputs.updatedMaintainers }}'.split(','); - for (const tscMember of newTscMembers) { - try { - await github.request('PUT /orgs/{org}/teams/{team_slug}/memberships/{username}', { - org: 'asyncapi', - team_slug: 'tsc_members', - username: tscMember - }); - } catch (error) { - console.error(`Failed to add ${tscMember} to the team:`, error); - } + const newTscMembers = ${{ needs.detect_tsc_changes.outputs.updatedMaintainers }}; + for (const tscMember of newTscMembers) { + try { + await github.request('PUT /orgs/asyncapi/teams/tsc_members/memberships/{username}', { + username: tscMember.githubUser + }); + core.info(`Successfully added ${tscMember.githubUser} to the team.`); + } catch (error) { + core.setFailed(`Failed to add ${tscMember.githubUser} to the team: ${error.message}`); } } - - addTscMembers(); outputs: newTscMember: ${{ needs.detect_tsc_changes.outputs.updatedMaintainers }} From d49de8e4fe496576fcf1fc8f3a3829e7c569cf19 Mon Sep 17 00:00:00 2001 From: 14Richa Date: Sun, 30 Jul 2023 13:44:07 +0530 Subject: [PATCH 15/22] added new jobs --- .github/workflows/tsc_management.yml | 101 +++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) diff --git a/.github/workflows/tsc_management.yml b/.github/workflows/tsc_management.yml index 9b5315429..a45ce97ef 100644 --- a/.github/workflows/tsc_management.yml +++ b/.github/workflows/tsc_management.yml @@ -189,6 +189,107 @@ jobs: git commit -m "Update Emeritus.yaml" git push https://${{ secrets.GH_TOKEN}}@github.com/asyncapi/community update-emeritus-${{ github.run_id }} + - name: Create PR + run: | + gh pr create --title "docs(community): update latest emeritus list" --body "Updated Emeritus list is available and this PR introduces changes with latest information about Emeritus" --head update-emeritus-${{ github.run_id }} + + remove_tsc_member: + needs: detect_tsc_changes + if: needs.detect_tsc_changes.outputs.updatedValue == 'false' + runs-on: ubuntu-latest + steps: + - name: Remove TSC members from the team + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.BOT_TOKEN }} + script: | + const removedMaintainers = ${{ needs.detect_tsc_changes.outputs.updatedMaintainers }}; + for (const maintainer of removedMaintainers) { + try { + await github.request('DELETE /orgs/richaOrg/teams/maintainers/memberships/{username}', { + username: maintainer.githubUser + }); + core.info(`Successfully removed ${maintainer.githubUser} from the team.`); + } catch (error) { + core.setFailed(`Failed to remove ${maintainer.githubUser} from the team: ${error.message}`); + } + } + outputs: + removedMaintainers: ${{ needs.detect_tsc_changes.outputs.updatedMaintainers }} + + remove_tsc_goodbye: + needs: remove_tsc_member + if: needs.remove_tsc_member.outputs.removedMaintainers != '' + runs-on: ubuntu-latest + steps: + - name: Display goodbye message to removed TSC members + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.BOT_TOKEN }} + script: | + const removedMaintainers = JSON.parse('${{ needs.remove_tsc_member.outputs.removedMaintainers }}'); + const removedTscMembers = removedMaintainers.map(maintainer => maintainer.githubUser); + + // Goodbye message to removed TSC members + const tscMessages = removedTscMembers.map(tscMember => { + return `@asyncapi/tsc_members We want to inform you that @${tscMember.trim().replace(/^@/, '')} is no longer a maintainer of any repository under AsyncAPI Initiative. It means this maintainer is also no longer a member of TSC.`; + }); + + const { owner, repo } = context.repo; + const { number: issue_number } = context.issue; + for (const message of tscMessages) { + github.rest.issues.createComment({ owner, repo, issue_number, body: message }); + } + + remove_tsc_emeritus: + needs: remove_tsc_member + if: needs.remove_tsc_member.outputs.removedMaintainers != '' + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v2 + + - name: Remove TSC members from Emeritus.yaml and print + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.BOT_TOKEN }} + script: | + const fs = require('fs'); + const path = './Emeritus.yaml'; + + // Read the current content of the file + let content = fs.readFileSync(path, 'utf8').trim(); // remove any trailing whitespaces + + // Parse the removedMaintainers JSON string to an array of objects + const removedMaintainers = JSON.parse('${{ needs.remove_tsc_member.outputs.removedMaintainers }}'); + + // Filter the maintainers whose updatedValue is false and prepare them for the yaml format + const removedTscMembers = removedMaintainers + .filter(maintainer => maintainer.updatedValue === false) + .map(maintainer => maintainer.githubUser.trim()); + + // Remove the TSC members from Emeritus.yaml + for (const tscMember of removedTscMembers) { + const regex = new RegExp(`^\\s*-\\s*${tscMember}\\s*$`, 'gm'); + content = content.replace(regex, ''); + } + + // Write the updated content back to the file + fs.writeFileSync(path, content); + + // 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 }} + + - name: Commit and push + run: | + git add . + git commit -m "Update Emeritus.yaml" + git push https://${{ secrets.GH_TOKEN}}@github.com/asyncapi/community update-emeritus-${{ github.run_id }} + - name: Create PR run: | gh pr create --title "docs(community): update latest emeritus list" --body "Updated Emeritus list is available and this PR introduces changes with latest information about Emeritus" --head update-emeritus-${{ github.run_id }} \ No newline at end of file From a1e5cb2b5b34fa72649cc3a9f85c42db58264f1b Mon Sep 17 00:00:00 2001 From: 14Richa Date: Sun, 30 Jul 2023 13:50:29 +0530 Subject: [PATCH 16/22] added slack job --- .github/workflows/tsc_management.yml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tsc_management.yml b/.github/workflows/tsc_management.yml index a45ce97ef..af93d388f 100644 --- a/.github/workflows/tsc_management.yml +++ b/.github/workflows/tsc_management.yml @@ -292,4 +292,17 @@ jobs: - name: Create PR run: | - gh pr create --title "docs(community): update latest emeritus list" --body "Updated Emeritus list is available and this PR introduces changes with latest information about Emeritus" --head update-emeritus-${{ github.run_id }} \ No newline at end of file + gh pr create --title "docs(community): update latest emeritus list" --body "Updated Emeritus list is available and this PR introduces changes with latest information about Emeritus" --head update-emeritus-${{ github.run_id }} + + notify_slack_on_failure: + if: always() && (needs.detect_tsc_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.remove_tsc_emeritus.result == 'failure' ) + needs: [detect_tsc_changes, add_tsc_member.result, display_message, update_emeritus,remove_tsc_goodbye, remove_tsc_member, remove_tsc_emeritus] + 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: 🚨 Welcome new contributor action failed 🚨 + SLACK_MESSAGE: Failed to post a message to new Maintainer + MSG_MINIMAL: true From 6513d8ff0f49d5703416823dcab802ea83144c9f Mon Sep 17 00:00:00 2001 From: 14Richa Date: Sun, 30 Jul 2023 13:51:40 +0530 Subject: [PATCH 17/22] token name fix --- .github/workflows/tsc_management.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tsc_management.yml b/.github/workflows/tsc_management.yml index af93d388f..2d8ced689 100644 --- a/.github/workflows/tsc_management.yml +++ b/.github/workflows/tsc_management.yml @@ -201,7 +201,7 @@ jobs: - name: Remove TSC members from the team uses: actions/github-script@v6 with: - github-token: ${{ secrets.BOT_TOKEN }} + github-token: ${{ secrets.GH_TOKEN }} script: | const removedMaintainers = ${{ needs.detect_tsc_changes.outputs.updatedMaintainers }}; for (const maintainer of removedMaintainers) { @@ -225,7 +225,7 @@ jobs: - name: Display goodbye message to removed TSC members uses: actions/github-script@v6 with: - github-token: ${{ secrets.BOT_TOKEN }} + github-token: ${{ secrets.GH_TOKEN }} script: | const removedMaintainers = JSON.parse('${{ needs.remove_tsc_member.outputs.removedMaintainers }}'); const removedTscMembers = removedMaintainers.map(maintainer => maintainer.githubUser); @@ -252,7 +252,7 @@ jobs: - name: Remove TSC members from Emeritus.yaml and print uses: actions/github-script@v6 with: - github-token: ${{ secrets.BOT_TOKEN }} + github-token: ${{ secrets.GH_TOKEN }} script: | const fs = require('fs'); const path = './Emeritus.yaml'; From cfb44748a91e70b33a67ac5cc830eb0eb89133e5 Mon Sep 17 00:00:00 2001 From: 14Richa Date: Sun, 30 Jul 2023 14:05:38 +0530 Subject: [PATCH 18/22] updated the api call of remove --- .github/workflows/tsc_management.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tsc_management.yml b/.github/workflows/tsc_management.yml index 2d8ced689..390124574 100644 --- a/.github/workflows/tsc_management.yml +++ b/.github/workflows/tsc_management.yml @@ -206,7 +206,7 @@ jobs: const removedMaintainers = ${{ needs.detect_tsc_changes.outputs.updatedMaintainers }}; for (const maintainer of removedMaintainers) { try { - await github.request('DELETE /orgs/richaOrg/teams/maintainers/memberships/{username}', { + await github.request('DELETE /orgs/asyncapi/teams/tsc_members/memberships/{username}', { username: maintainer.githubUser }); core.info(`Successfully removed ${maintainer.githubUser} from the team.`); From 7e4750fcbcea40155195bb7a24e5cad1792df607 Mon Sep 17 00:00:00 2001 From: 14Richa Date: Mon, 31 Jul 2023 15:06:28 +0530 Subject: [PATCH 19/22] removed job --- .github/workflows/tsc_management.yml | 53 ---------------------------- 1 file changed, 53 deletions(-) diff --git a/.github/workflows/tsc_management.yml b/.github/workflows/tsc_management.yml index 390124574..c2e5731e5 100644 --- a/.github/workflows/tsc_management.yml +++ b/.github/workflows/tsc_management.yml @@ -140,59 +140,6 @@ jobs: const { number: issue_number } = context.issue; github.rest.issues.createComment({ owner, repo, issue_number, body: welcomeMessage }); - update_emeritus: - needs: add_tsc_member - if: needs.add_tsc_member.outputs.newTscMember != '' - runs-on: ubuntu-latest - steps: - - name: Check out code - uses: actions/checkout@v2 - - - name: Add TSC members to Emeritus.yaml and print - uses: actions/github-script@v6 - with: - github-token: ${{ secrets.GH_TOKEN }} - script: | - const fs = require('fs'); - const path = './Emeritus.yaml'; - - // Read the current content of the file - let content = fs.readFileSync(path, 'utf8').trim(); // remove any trailing whitespaces - - // Parse the updatedMaintainers JSON string to an array of objects - const updatedMaintainers = JSON.parse('${{ needs.add_tsc_member.outputs.newTscMember }}'); - - // Filter the maintainers whose updatedValue is true and prepare them for the yaml format - const addedTscMembers = updatedMaintainers - .filter(maintainer => maintainer.updatedValue === true) - .map(maintainer => ` - ${maintainer.githubUser.trim()}`) - .join('\n'); - - // Append the added maintainers to the file content - if (addedTscMembers) { - content = content + '\n' + addedTscMembers; - } - - // Write the updated content back to the file - fs.writeFileSync(path, content); - - // 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 }} - - - name: Commit and push - run: | - git add . - git commit -m "Update Emeritus.yaml" - git push https://${{ secrets.GH_TOKEN}}@github.com/asyncapi/community update-emeritus-${{ github.run_id }} - - - name: Create PR - run: | - gh pr create --title "docs(community): update latest emeritus list" --body "Updated Emeritus list is available and this PR introduces changes with latest information about Emeritus" --head update-emeritus-${{ github.run_id }} - remove_tsc_member: needs: detect_tsc_changes if: needs.detect_tsc_changes.outputs.updatedValue == 'false' From 1144ec98f7f702347261f624cba1b1365e97bc1e Mon Sep 17 00:00:00 2001 From: 14Richa Date: Mon, 31 Jul 2023 15:08:06 +0530 Subject: [PATCH 20/22] minor fix --- .github/workflows/tsc_management.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/tsc_management.yml b/.github/workflows/tsc_management.yml index c2e5731e5..f4c23ef17 100644 --- a/.github/workflows/tsc_management.yml +++ b/.github/workflows/tsc_management.yml @@ -188,7 +188,7 @@ jobs: github.rest.issues.createComment({ owner, repo, issue_number, body: message }); } - remove_tsc_emeritus: + update_emeritus: needs: remove_tsc_member if: needs.remove_tsc_member.outputs.removedMaintainers != '' runs-on: ubuntu-latest @@ -196,7 +196,7 @@ jobs: - name: Check out code uses: actions/checkout@v2 - - name: Remove TSC members from Emeritus.yaml and print + - name: Add Former TSC members to Emeritus.yaml and print uses: actions/github-script@v6 with: github-token: ${{ secrets.GH_TOKEN }} @@ -213,12 +213,12 @@ jobs: // Filter the maintainers whose updatedValue is false and prepare them for the yaml format const removedTscMembers = removedMaintainers .filter(maintainer => maintainer.updatedValue === false) - .map(maintainer => maintainer.githubUser.trim()); + .map(maintainer => ` - ${maintainer.githubUser.trim()}`) + .join('\n'); - // Remove the TSC members from Emeritus.yaml - for (const tscMember of removedTscMembers) { - const regex = new RegExp(`^\\s*-\\s*${tscMember}\\s*$`, 'gm'); - content = content.replace(regex, ''); + // Append the added maintainers to the file content + if (removedTscMembers) { + content = content + '\n' + removedTscMembers; } // Write the updated content back to the file From 53c6fad3d5f32e761f8a574bc2cd35b6c0aff954 Mon Sep 17 00:00:00 2001 From: 14Richa Date: Mon, 31 Jul 2023 15:52:02 +0530 Subject: [PATCH 21/22] changed job name --- .github/workflows/tsc_management.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/tsc_management.yml b/.github/workflows/tsc_management.yml index f4c23ef17..e1be7232f 100644 --- a/.github/workflows/tsc_management.yml +++ b/.github/workflows/tsc_management.yml @@ -7,7 +7,7 @@ on: - 'MAINTAINERS.yaml' jobs: - detect_tsc_changes: + detect_tsc_membership_changes: if: github.event.pull_request.merged name: Update TSC Member runs-on: ubuntu-latest @@ -83,8 +83,8 @@ jobs: updatedMaintainers: ${{ steps.compare-files.outputs.updatedMaintainers }} add_tsc_member: - needs: detect_tsc_changes - if: needs.detect_tsc_changes.outputs.updatedValue == 'true' + needs: detect_tsc_membership_changes + if: needs.detect_tsc_membership_changes.outputs.updatedValue == 'true' runs-on: ubuntu-latest steps: - name: Add new TSC members to the team @@ -92,7 +92,7 @@ jobs: with: github-token: ${{ secrets.GH_TOKEN }} script: | - const newTscMembers = ${{ needs.detect_tsc_changes.outputs.updatedMaintainers }}; + const newTscMembers = ${{ needs.detect_tsc_membership_changes.outputs.updatedMaintainers }}; for (const tscMember of newTscMembers) { try { await github.request('PUT /orgs/asyncapi/teams/tsc_members/memberships/{username}', { @@ -104,7 +104,7 @@ jobs: } } outputs: - newTscMember: ${{ needs.detect_tsc_changes.outputs.updatedMaintainers }} + newTscMember: ${{ needs.detect_tsc_membership_changes.outputs.updatedMaintainers }} display_message: needs: add_tsc_member @@ -141,8 +141,8 @@ jobs: github.rest.issues.createComment({ owner, repo, issue_number, body: welcomeMessage }); remove_tsc_member: - needs: detect_tsc_changes - if: needs.detect_tsc_changes.outputs.updatedValue == 'false' + needs: detect_tsc_membership_changes + if: needs.detect_tsc_membership_changes.outputs.updatedValue == 'false' runs-on: ubuntu-latest steps: - name: Remove TSC members from the team @@ -150,7 +150,7 @@ jobs: with: github-token: ${{ secrets.GH_TOKEN }} script: | - const removedMaintainers = ${{ needs.detect_tsc_changes.outputs.updatedMaintainers }}; + const removedMaintainers = ${{ needs.detect_tsc_membership_changes.outputs.updatedMaintainers }}; for (const maintainer of removedMaintainers) { try { await github.request('DELETE /orgs/asyncapi/teams/tsc_members/memberships/{username}', { @@ -162,7 +162,7 @@ jobs: } } outputs: - removedMaintainers: ${{ needs.detect_tsc_changes.outputs.updatedMaintainers }} + removedMaintainers: ${{ needs.detect_tsc_membership_changes.outputs.updatedMaintainers }} remove_tsc_goodbye: needs: remove_tsc_member @@ -242,8 +242,8 @@ jobs: gh pr create --title "docs(community): update latest emeritus list" --body "Updated Emeritus list is available and this PR introduces changes with latest information about Emeritus" --head update-emeritus-${{ github.run_id }} notify_slack_on_failure: - if: always() && (needs.detect_tsc_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.remove_tsc_emeritus.result == 'failure' ) - needs: [detect_tsc_changes, add_tsc_member.result, display_message, update_emeritus,remove_tsc_goodbye, remove_tsc_member, remove_tsc_emeritus] + 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.remove_tsc_emeritus.result == 'failure' ) + needs: [detect_tsc_membership_changes, add_tsc_member.result, display_message, update_emeritus,remove_tsc_goodbye, remove_tsc_member, remove_tsc_emeritus] runs-on: ubuntu-latest steps: - name: Report workflow run status to Slack From 2d59f91dd01f9fae06eb0bdd2d9aceaf8334a964 Mon Sep 17 00:00:00 2001 From: 14Richa Date: Mon, 31 Jul 2023 15:54:39 +0530 Subject: [PATCH 22/22] changed msg content --- .github/workflows/tsc_management.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tsc_management.yml b/.github/workflows/tsc_management.yml index e1be7232f..98f5b7f5d 100644 --- a/.github/workflows/tsc_management.yml +++ b/.github/workflows/tsc_management.yml @@ -133,7 +133,11 @@ jobs: return `@${tscMember.trim().replace(/^@/, '')} Welcome to the AsyncAPI Initiative's TSC Teams! We value your expertise and look forward to collaborating with you. Feel free to engage in discussions and share your ideas with the TSC. If you have any questions, reach out on Slack or comment on this pull request. - Congratulations, and let's make great things happen together!` + We use this team to mention in different discussions in different places in GitHub where Maintainer's opinion is needed or even voting on some topic. Once Maintainers are mentioned: + - You get GitHub notification + - We also drop notification in our slack in #95_bot-maintainers-mentioned channel + - We drop an email to people that subscribed to Maintainer news here https://www.asyncapi.com/community/maintainers + Pick the channel for notifications that you prefer. Welcome aboard! We are excited to have you as part of the team.` }).join('\n\n'); const { owner, repo } = context.repo;