Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: fix in update maintainer workflow #223

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions .github/workflows/update-maintainers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ on:
jobs:
update-maintainers:
runs-on: ubuntu-latest

env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
steps:
- name: Checkout main branch
uses: actions/checkout@v3
Expand All @@ -31,7 +32,7 @@ jobs:
uses: actions/checkout@v3
with:
repository: asyncapi/community
token: ${{ secrets.GH_TOKEN}}
token: ${{ env.GITHUB_TOKEN }}
path: community

- name: Setup Node.js
Expand All @@ -45,7 +46,7 @@ jobs:
- name: Compare CODEOWNERS
id: compare-codeowners
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
GH_TOKEN: ${{ env.GITHUB_TOKEN }}
uses: actions/github-script@v6
with:
script: |
Expand Down Expand Up @@ -94,16 +95,19 @@ jobs:
continue; // Skip the iteration for bot accounts
}

const maintainer = maintainers.find(maintainer => maintainer.github === username);
const maintainer = maintainers.find(maintainer => maintainer.github === username.toLowerCase());
if (!maintainer) {
const { data } = await github.rest.users.getByUsername({ username });
const twitterUsername = data.twitter_username;
maintainers.push({
const newMaintainer = {
github: username,
twitter: twitterUsername,
isTscMember: false,
repos: [repoName]
});
};
if (twitterUsername) {
newMaintainer.twitter = twitterUsername;
}
maintainers.push(newMaintainer);
core.info('Added maintainer:', username);
} else {
// If the maintainer already exists, check if the current repo is in their list
Expand Down Expand Up @@ -151,9 +155,11 @@ jobs:
- name: Commit and push
working-directory: ./community
run: |
git config --global user.email "[email protected]"
git config --global user.name "asyncapi-bot"
git add .
git commit -m "Update MAINTAINERS.yaml"
git push https://${{ secrets.GH_TOKEN}}@github.com/asyncapi/community update-maintainers-${{ github.run_id }}
git push https://${{ env.GITHUB_TOKEN }}@github.com/asyncapi/community

- name: Create PR
working-directory: ./community
Expand Down