Skip to content

Commit

Permalink
ci: fix and improve automation around MAINTAINERS.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
aeworxet committed Feb 11, 2025
1 parent ffcb9b1 commit 414389a
Showing 1 changed file with 16 additions and 19 deletions.
35 changes: 16 additions & 19 deletions .github/workflows/maintainer_management.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ on:
paths:
- 'MAINTAINERS.yaml'

env:
GH_TOKEN_ORG_ADMIN: ${{ secrets.GH_TOKEN_ORG_ADMIN }}

jobs:
detect_maintainer_changes:
if: github.event.pull_request.merged
Expand Down Expand Up @@ -92,31 +95,24 @@ jobs:
- name: Invite new maintainers to the organization
uses: actions/github-script@v6
with:
github-token: ${{ env.GH_TOKEN_ORG_ADMIN }}
script: |
console.log(process.env);
const newMaintainers = '${{ needs.detect_maintainer_changes.outputs.newMaintainers }}'.split(',');
const promises = newMaintainers.map(async (maintainer) => {
for (const maintainer of newMaintainers) {
try {
const response = await fetch(`https://api.github.com/orgs/asyncapi/teams/maintainers/memberships/${maintainer}`, {
method: 'PUT',
headers: {
'Authorization': 'token ${{ secrets.GH_TOKEN_ORG_ADMIN }}',
},
await github.request('PUT /orgs/{org}/memberships/{username}', {
org: 'asyncapi',
username: maintainer
});
const data = await response.json();
console.log(data);
} catch (error) {
core.setFailed(`Failed to add ${maintainer} to the organization: ${error.message}`);
}
});
await Promise.all(promises);
}
- name: Add new maintainers to the team
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GH_TOKEN }}
github-token: ${{ env.GH_TOKEN_ORG_ADMIN }}
script: |
const newMaintainers = '${{ needs.detect_maintainer_changes.outputs.newMaintainers }}'.split(',');
for (const maintainer of newMaintainers) {
Expand All @@ -142,7 +138,7 @@ jobs:
- name: Display welcome message for new maintainers
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GH_TOKEN }}
github-token: ${{ env.GH_TOKEN_ORG_ADMIN }}
script: |
const newMaintainers = "${{ needs.add_maintainer.outputs.newMaintainers }}".split(",");
console.log(`New maintainers: ${newMaintainers}`);
Expand All @@ -166,7 +162,7 @@ jobs:
- name: Remove maintainers from the organization
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GH_TOKEN }}
github-token: ${{ env.GH_TOKEN_ORG_ADMIN }}
script: |
const removedMaintainers = '${{ needs.detect_maintainer_changes.outputs.removedMaintainers }}'.split(',');
for (const maintainer of removedMaintainers) {
Expand All @@ -193,7 +189,7 @@ jobs:
- name: Display goodbye message to removed maintainers
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GH_TOKEN }}
github-token: ${{ env.GH_TOKEN_ORG_ADMIN }}
script: |
const removedMaintainers = "${{ needs.remove_maintainer.outputs.removedMaintainers }}".split(",");
const removedTscMembers = "${{ needs.remove_maintainer.outputs.removedTscMembers }}".split(",");
Expand Down Expand Up @@ -224,7 +220,7 @@ jobs:
- name: Add TSC members to Emeritus.yaml and print
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GH_TOKEN }}
github-token: ${{ env.GH_TOKEN_ORG_ADMIN }}
script: |
const fs = require('fs');
const path = './Emeritus.yaml';
Expand Down Expand Up @@ -256,7 +252,8 @@ jobs:
run: |
git add .
git commit -m "Update Emeritus.yaml"
git push https://${{ secrets.GH_TOKEN}}@github.com/asyncapi/community update-emeritus-${{ github.run_id }}
git remote set-url origin https://x-access-token:${{ env.GH_TOKEN_ORG_ADMIN }}@github.com/asyncapi/community.git
git push origin update-emeritus-${{ github.run_id }}
- name: Create PR
run: |
Expand Down

0 comments on commit 414389a

Please sign in to comment.