Skip to content

Commit

Permalink
refactor: change the maintainers update workflow event target (#1026)
Browse files Browse the repository at this point in the history
  • Loading branch information
14Richa authored Sep 4, 2023
1 parent 0423653 commit ac7af99
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions .github/workflows/update-maintainers.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
name: Update MAINTAINERS.yaml in community repo

on:
pull_request:
types: [closed]
push:
branches:
- master
paths:
- 'CODEOWNERS'

jobs:
update-maintainers:
if: github.event.pull_request.merged
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

0 comments on commit ac7af99

Please sign in to comment.