From 4d7a08d96e57dd408260dabbe662a8caf60182f0 Mon Sep 17 00:00:00 2001 From: Viacheslav Turovskyi Date: Mon, 27 Jan 2025 10:02:49 +0000 Subject: [PATCH 1/5] ci: fix and improve automation around `MAINTAINERS.yaml` --- .github/workflows/maintainer_management.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/maintainer_management.yml b/.github/workflows/maintainer_management.yml index bbe3334c76..27f3fc7c96 100644 --- a/.github/workflows/maintainer_management.yml +++ b/.github/workflows/maintainer_management.yml @@ -94,7 +94,7 @@ jobs: - name: Invite new maintainers to the organization uses: actions/github-script@v6 with: - github-token: ${{ env.GH_TOKEN }} + github-token: ${{ secrets.GH_TOKEN }} script: | const newMaintainers = '${{ needs.detect_maintainer_changes.outputs.newMaintainers }}'.split(','); for (const maintainer of newMaintainers) { @@ -111,7 +111,7 @@ jobs: - name: Add new maintainers to the team uses: actions/github-script@v6 with: - github-token: ${{ env.GH_TOKEN }} + github-token: ${{ secrets.GH_TOKEN }} script: | const newMaintainers = '${{ needs.detect_maintainer_changes.outputs.newMaintainers }}'.split(','); for (const maintainer of newMaintainers) { @@ -161,7 +161,7 @@ jobs: - name: Remove maintainers from the organization uses: actions/github-script@v6 with: - github-token: ${{ env.GH_TOKEN }} + github-token: ${{ secrets.GH_TOKEN }} script: | const removedMaintainers = '${{ needs.detect_maintainer_changes.outputs.removedMaintainers }}'.split(','); for (const maintainer of removedMaintainers) { @@ -187,7 +187,7 @@ jobs: - name: Display goodbye message to removed maintainers uses: actions/github-script@v6 with: - github-token: ${{ env.GH_TOKEN }} + github-token: ${{ secrets.GH_TOKEN }} script: | const removedMaintainers = "${{ needs.remove_maintainer.outputs.removedMaintainers }}".split(","); const removedTscMembers = "${{ needs.remove_maintainer.outputs.removedTscMembers }}".split(","); @@ -218,7 +218,7 @@ jobs: - name: Add TSC members to Emeritus.yaml and print uses: actions/github-script@v6 with: - github-token: ${{ env.GH_TOKEN }} + github-token: ${{ secrets.GH_TOKEN }} script: | const fs = require('fs'); const path = './Emeritus.yaml'; From 1cb44d94d083f3228a72b33b6081f57dcf3238b4 Mon Sep 17 00:00:00 2001 From: Viacheslav Turovskyi Date: Mon, 3 Feb 2025 12:05:22 +0000 Subject: [PATCH 2/5] ci: fix and improve automation around `MAINTAINERS.yaml` --- .github/workflows/maintainer_management.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/maintainer_management.yml b/.github/workflows/maintainer_management.yml index 27f3fc7c96..20a323b8fe 100644 --- a/.github/workflows/maintainer_management.yml +++ b/.github/workflows/maintainer_management.yml @@ -5,8 +5,6 @@ on: types: [closed] paths: - 'MAINTAINERS.yaml' -env: - GH_TOKEN: ${{ secrets.GH_TOKEN }} jobs: detect_maintainer_changes: @@ -100,6 +98,9 @@ jobs: for (const maintainer of newMaintainers) { try { await github.request('PUT /orgs/{org}/memberships/{username}', { + headers: { + authorization: 'token ${{ secrets.GH_TOKEN }}', + }, org: 'asyncapi', username: maintainer }); From 026f49983b1d3f58610b85389913cfb69fedc1af Mon Sep 17 00:00:00 2001 From: Viacheslav Turovskyi Date: Tue, 4 Feb 2025 00:14:26 +0000 Subject: [PATCH 3/5] ci: fix and improve automation around `MAINTAINERS.yaml` --- .github/workflows/maintainer_management.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/maintainer_management.yml b/.github/workflows/maintainer_management.yml index 20a323b8fe..4752af01dd 100644 --- a/.github/workflows/maintainer_management.yml +++ b/.github/workflows/maintainer_management.yml @@ -73,11 +73,11 @@ jobs: - name: Debug newMaintainers output run: | - echo "newMaintainers = $newMaintainers" + echo "newMaintainers = ${{ steps.compare-files.outputs.newMaintainers }}" - name: Debug removedMaintainers output run: | - echo "removedMaintainers = $removedMaintainers" + echo "removedMaintainers = ${{ steps.compare-files.outputs.removedMaintainers }}" outputs: newMaintainers: ${{ steps.compare-files.outputs.newMaintainers }} @@ -167,7 +167,8 @@ jobs: const removedMaintainers = '${{ needs.detect_maintainer_changes.outputs.removedMaintainers }}'.split(','); for (const maintainer of removedMaintainers) { try { - await github.request('DELETE /orgs/asyncapi/memberships/{username}', { + await github.request('DELETE /orgs/{org}/memberships/{username}', { + org: 'asyncapi', username: maintainer }); core.info(`Successfully removed ${maintainer} from the organization.`); @@ -268,4 +269,4 @@ jobs: SLACK_WEBHOOK: ${{secrets.SLACK_CI_FAIL_NOTIFY}} SLACK_TITLE: 🚨 Maintainer Management Workflow failed 🚨 SLACK_MESSAGE: Failed to post a message to new Maintainer - MSG_MINIMAL: true \ No newline at end of file + MSG_MINIMAL: true From c3ea6b48f40770cf007381ef54d51de4d27622e6 Mon Sep 17 00:00:00 2001 From: Viacheslav Turovskyi Date: Tue, 4 Feb 2025 01:42:07 +0000 Subject: [PATCH 4/5] ci: fix and improve automation around `MAINTAINERS.yaml` --- .github/workflows/maintainer_management.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/maintainer_management.yml b/.github/workflows/maintainer_management.yml index 4752af01dd..2c857b74ac 100644 --- a/.github/workflows/maintainer_management.yml +++ b/.github/workflows/maintainer_management.yml @@ -6,6 +6,11 @@ on: paths: - 'MAINTAINERS.yaml' +env: + GH_TOKEN: ${{ secrets.GH_TOKEN }} + +permissions: write-all + jobs: detect_maintainer_changes: if: github.event.pull_request.merged @@ -92,14 +97,15 @@ jobs: - name: Invite new maintainers to the organization uses: actions/github-script@v6 with: - github-token: ${{ secrets.GH_TOKEN }} + github-token: ${{ secrets.GITHUB_TOKEN }} script: | + const ghToken = process.env.GH_TOKEN; const newMaintainers = '${{ needs.detect_maintainer_changes.outputs.newMaintainers }}'.split(','); for (const maintainer of newMaintainers) { try { await github.request('PUT /orgs/{org}/memberships/{username}', { headers: { - authorization: 'token ${{ secrets.GH_TOKEN }}', + authorization: `token ${ghToken}`, }, org: 'asyncapi', username: maintainer From ec9bb688c8d065845f840e4311d13387a202bcf8 Mon Sep 17 00:00:00 2001 From: Viacheslav Turovskyi Date: Thu, 6 Feb 2025 14:33:37 +0200 Subject: [PATCH 5/5] ci: fix and improve automation around `MAINTAINERS.yaml` --- .github/workflows/maintainer_management.yml | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/.github/workflows/maintainer_management.yml b/.github/workflows/maintainer_management.yml index 2c857b74ac..235e91b8ad 100644 --- a/.github/workflows/maintainer_management.yml +++ b/.github/workflows/maintainer_management.yml @@ -9,8 +9,6 @@ on: env: GH_TOKEN: ${{ secrets.GH_TOKEN }} -permissions: write-all - jobs: detect_maintainer_changes: if: github.event.pull_request.merged @@ -99,17 +97,21 @@ jobs: with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | + console.log(process.env) const ghToken = process.env.GH_TOKEN; const newMaintainers = '${{ needs.detect_maintainer_changes.outputs.newMaintainers }}'.split(','); + for (const maintainer of newMaintainers) { try { - await github.request('PUT /orgs/{org}/memberships/{username}', { - headers: { - authorization: `token ${ghToken}`, - }, - org: 'asyncapi', - username: maintainer - }); + (async () => { + await fetch(`https://api.github.com/orgs/asyncapi/teams/maintainers/memberships/${maintainer}`, { + method: 'PUT', + headers: { + 'Authorization': `token ${ghToken}`, + }, + }).then(response => response.json()) + .then(data => console.log(data)); + })() } catch (error) { core.setFailed(`Failed to add ${maintainer} to the organization: ${error.message}`); }