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 8, 2025
1 parent 7d05d40 commit ffcb9b1
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions .github/workflows/maintainer_management.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ on:
paths:
- 'MAINTAINERS.yaml'

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

jobs:
detect_maintainer_changes:
if: github.event.pull_request.merged
Expand Down Expand Up @@ -96,27 +92,26 @@ jobs:
- name: Invite new maintainers to the organization
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
console.log(process.env);
const ghTokenOrgAdmin = process.env.GH_TOKEN_ORG_ADMIN;
const newMaintainers = '${{ needs.detect_maintainer_changes.outputs.newMaintainers }}'.split(',');
for (const maintainer of newMaintainers) {
const promises = newMaintainers.map(async (maintainer) => {
try {
(async () => {
await fetch(`https://api.github.com/orgs/asyncapi/teams/maintainers/memberships/${maintainer}`, {
method: 'PUT',
headers: {
'Authorization': `token ${ghTokenOrgAdmin}`,
},
}).then(response => response.json())
.then(data => console.log(data));
})()
const response = await fetch(`https://api.github.com/orgs/asyncapi/teams/maintainers/memberships/${maintainer}`, {
method: 'PUT',
headers: {
'Authorization': 'token ${{ secrets.GH_TOKEN_ORG_ADMIN }}',
},
});
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
Expand Down

0 comments on commit ffcb9b1

Please sign in to comment.