The "Update MAINTAINERS.yaml file" workflow, defined in the community
repository performs a complete refresh by fetching all public repositories under AsyncAPI and their respective CODEOWNERS
files.
The "Update MAINTAINERS.yaml file" workflow is executed in the following scenarios:
- Weekly Schedule: The workflow runs automatically every week. It is useful, e.g. when some repositories are archived, renamed, or when a GitHub user account is removed.
- On Change: When a
CODEOWNERS
file is changed in any repository under the AsyncAPI organization, the related repository triggers the workflow by emitting thetrigger-maintainers-update
event. - Manual Trigger: Users can manually trigger the workflow as needed.
- Load Cache: Attempt to read previously cached data from
github.api.cache.json
to optimize API calls. - List All Repositories: Retrieve a list of all public repositories under the AsyncAPI organization, skipping any repositories specified in the
IGNORED_REPOSITORIES
environment variable. - Fetch
CODEOWNERS
Files: For each repository:- Detect the default branch (e.g.,
main
,master
, or a custom branch). - Check for
CODEOWNERS
files in all valid locations as specified in the GitHub documentation.
- Detect the default branch (e.g.,
- Process
CODEOWNERS
Files:- Extract GitHub usernames from each
CODEOWNERS
file, excluding emails, team names, and users specified by theIGNORED_USERS
environment variable. - Retrieve profile information for each unique GitHub username.
- Collect a fresh list of repositories currently owned by each GitHub user.
- Extract GitHub usernames from each
- Refresh Maintainers List: Iterate through the existing maintainers list:
- Delete the entry if it:
- Refers to a deleted GitHub account.
- Was not found in any
CODEOWNERS
file across all repositories in the AsyncAPI organization.
- Otherwise, update only the
repos
property.
- Delete the entry if it:
- Add New Maintainers: Append any new maintainers not present in the previous list.
- Changes Summary: Provide details on why a maintainer was removed or changed directly on the GitHub Action summary page.
- Save Cache: Save retrieved data in
github.api.cache.json
.
- Concurrency: Ensures the workflow does not run multiple times concurrently to avoid conflicts.
- Wait for PRs to be Merged: The workflow waits for pending pull requests to be merged before execution. If the merged pull request addresses all necessary fixes, it prevents unnecessary executions.
Since the job performs a full refresh each time, resolving conflicts is straightforward:
- Close the pull request with conflicts.
- Navigate to the "Update MAINTAINERS.yaml file" workflow.
- Trigger it manually by clicking "Run workflow".
Each execution of this action performs a full refresh through the following API calls:
ListRepos(AsyncAPI) # 1 call using GraphQL - not cached.
for each Repo
GetCodeownersFile(Repo) # N calls using REST API - all are cached. N refers to the number of public repositories under AsyncAPI.
for each codeowner
GetGitHubProfile(owner) # Y calls using REST API - all are cached. Y refers to unique GitHub users found across all CODEOWNERS files.
To avoid hitting the GitHub API rate limits, conditional requests are used via if-modified-since
. The API responses are saved into a github.api.cache.json
file, which is later uploaded as a GitHub action cache item.