-
Notifications
You must be signed in to change notification settings - Fork 10
Add generated ARD catalog compatibility #17
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| name: Catalog | ||
|
|
||
| on: | ||
| pull_request: | ||
| paths: | ||
| - "catalog/*/*.json" | ||
| - "ai-catalog.json" | ||
| - "scripts/generate_ai_catalog.py" | ||
| - "tests/test_generate_ai_catalog.py" | ||
| - ".github/workflows/catalog.yml" | ||
| push: | ||
| branches: | ||
| - main | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| actions: write | ||
| contents: write | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| update: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }} | ||
| ref: ${{ github.event.pull_request.head.ref || github.ref }} | ||
| - run: python3 -m unittest discover -s tests | ||
| - run: python3 scripts/generate_ai_catalog.py | ||
| - name: Update pull request | ||
| if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| HEAD_REF: ${{ github.event.pull_request.head.ref }} | ||
| run: | | ||
| git diff --quiet -- ai-catalog.json && exit 0 | ||
| git config user.name github-actions[bot] | ||
| git config user.email 41898282+github-actions[bot]@users.noreply.github.com | ||
| git add ai-catalog.json | ||
| git commit -m "Update generated ARD catalog" | ||
| git push origin "HEAD:$HEAD_REF" | ||
| if gh workflow view catalog.yml >/dev/null 2>&1; then | ||
| gh workflow run catalog.yml --ref "$HEAD_REF" | ||
| fi | ||
| - name: Open fallback pull request | ||
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| run: | | ||
| git diff --quiet -- ai-catalog.json && exit 0 | ||
| branch=automation/update-ai-catalog | ||
| git config user.name github-actions[bot] | ||
| git config user.email 41898282+github-actions[bot]@users.noreply.github.com | ||
| git switch -c "$branch" | ||
| git add ai-catalog.json | ||
| git commit -m "Update generated ARD catalog" | ||
| git push --force origin "$branch" | ||
| if [ "$(gh pr list --head "$branch" --state open --json number --jq length)" = 0 ]; then | ||
| gh pr create \ | ||
| --base main \ | ||
| --head "$branch" \ | ||
| --title "Update generated ARD catalog" \ | ||
| --body "Regenerates \`ai-catalog.json\` from the canonical entries and live MCP catalog." | ||
| fi | ||
| gh workflow run catalog.yml --ref "$branch" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should make this workflow a little more robust. I think it would be better if we didn't have to rely on contributors to run the generate script at all.
I like the idea of a pull request trigger. If it's for a PR, could we have the workflow run the script and then add the generated catalog to that PR (commit + push)?
Could we then add a trigger for push to main? I'm thinking of this as a fallback. That would cause it to run on PR merge. Ideally, this would always just result in no changes. If it ever does result in a changed catalog file, though, could we have it then open a PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implemented. Same-repository PRs now regenerate and push
ai-catalog.jsonback to the PR branch. Pushes tomainregenerate as a fallback and create or update anautomation/update-ai-catalogPR when needed. Fork workflows stay read-only for security; they validate the generator, and the main fallback handles any resulting drift after merge.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very much like the idea :D