-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add GitHub Models automation workflows #6560
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
RitikaPahwa4444
merged 7 commits into
commons-app:main
from
Richard-Mackey:github-models-integration
Nov 25, 2025
+198
−0
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8a1560b
Add GitHub Models automation workflows
Richard-Mackey 56d7239
Address review feedback: replace PR with pull request and update guid…
Richard-Mackey 069d4cd
Address review feedback: check if issue already assigned, change 'enh…
Richard-Mackey b5ce6db
Merge branch 'main' into github-models-integration
RitikaPahwa4444 29e785b
Remove temperature parameter - no longer supported by ai-inference ac…
Richard-Mackey 31db879
Merge branch 'github-models-integration' of github.com:Richard-Mackey…
Richard-Mackey 9bcb579
Merge branch 'main' into github-models-integration
RitikaPahwa4444 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,88 @@ | ||
| on: | ||
| issue_comment: | ||
| types: [created] | ||
|
|
||
| permissions: | ||
| issues: write | ||
| models: read | ||
|
|
||
| jobs: | ||
| auto-assign: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Check if requesting assignment | ||
| uses: actions/ai-inference@v1 | ||
| id: check-request | ||
| with: | ||
| prompt: | | ||
| Does this comment ask to be assigned to the issue? | ||
| Respond with only "yes" or "no". | ||
|
|
||
| Comment: ${{ github.event.comment.body }} | ||
| model: openai/gpt-4o-mini | ||
|
|
||
| - name: Handle assignment | ||
| if: steps.check-request.outputs.response == 'yes' | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| // Check if the issue is already assigned | ||
| const issue = await github.rest.issues.get({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: context.issue.number | ||
| }); | ||
|
|
||
| if (issue.data.assignees.length > 0) { | ||
| // Issue is already assigned to someone else | ||
| await github.rest.issues.createComment({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: context.issue.number, | ||
| body: "This issue has already been assigned. Please find another issue to work on: https://github.com/commons-app/apps-android-commons/issues?q=is%3Aissue%20state%3Aopen%20type%3ABug%20no%3Aassignee%20-label%3A%22low%20priority%22%20-label%3Adebated%20-label%3Aupstream" | ||
| }); | ||
| return; | ||
| } | ||
|
|
||
| // Check commenter's existing assignments | ||
| const assignedIssues = await github.rest.issues.listForRepo({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| assignee: context.actor, | ||
| state: 'open' | ||
| }); | ||
|
|
||
| const pullRequests = await github.rest.pulls.list({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| creator: context.actor, | ||
| state: 'open' | ||
| }); | ||
|
|
||
| // No assigned issues - safe to assign | ||
| if (assignedIssues.data.length === 0) { | ||
| await github.rest.issues.addAssignees({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: context.issue.number, | ||
| assignees: [context.actor] | ||
| }); | ||
| } | ||
| // Has assigned issues but no PRs - ask them to finish first | ||
| else if (assignedIssues.data.length > 0 && pullRequests.data.length === 0) { | ||
| await github.rest.issues.createComment({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: context.issue.number, | ||
| body: "Please finish your previous assignment before you request to work on another" | ||
| }); | ||
| } | ||
| // Has assigned issues WITH PRs - they're making progress, assign them | ||
| else { | ||
| await github.rest.issues.addAssignees({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: context.issue.number, | ||
| assignees: [context.actor] | ||
| }); | ||
| } | ||
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,45 @@ | ||
| name: Check Pull Request Scope | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [opened, synchronize] | ||
|
|
||
| permissions: | ||
| pull-requests: write | ||
| models: read | ||
|
|
||
| jobs: | ||
| check-scope: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| # Use AI to detect if pull request mixes unrelated changes | ||
| - name: Analyse pull request changes | ||
| uses: actions/ai-inference@v1 | ||
| id: analyze | ||
| with: | ||
| prompt: | | ||
| Analyse this pull request to determine if it contains unrelated changes. | ||
| A pull request should modify only the code that really needs to be modified to solve the issue at hand. Changes unrelated to the issue at hand can be made in other pull requests. | ||
|
|
||
| Examples of changes that are not acceptable: | ||
| * Fixing indentation or formatting in unrelated files or in unrelated parts of a file. | ||
| * Adding or removing unrelated comments. | ||
|
|
||
| Pull Request Title: ${{ github.event.pull_request.title }} | ||
| Pull Request Description: ${{ github.event.pull_request.body }} | ||
|
|
||
| Does this pull request appear to mix unrelated changes? Respond with only "yes" or "no". | ||
| model: openai/gpt-4o-mini | ||
|
|
||
| # If unrelated changes detected, remind contributor of guidelines | ||
| - name: Comment if unrelated changes detected | ||
| if: steps.analyze.outputs.response == 'yes' | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| await github.rest.issues.createComment({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: context.issue.number, | ||
| body: "This pull request appears to contain unrelated changes. A pull request should modify only the code that really needs to be modified to solve the issue at hand. Please review [CONTRIBUTING.md](https://github.com/commons-app/apps-android-commons/blob/master/CONTRIBUTING.md) and consider splitting this into separate pull requests." | ||
| }); |
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,24 @@ | ||
| name: Detect duplicate issues | ||
|
|
||
| on: | ||
| issues: | ||
| types: [opened, reopened] | ||
|
|
||
| permissions: | ||
| models: read | ||
| issues: write | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.event.issue.number }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| continuous-triage-dedup: | ||
| if: ${{ github.event.issue.user.type != 'Bot' }} | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: pelikhan/action-genai-issue-dedup@v0 | ||
| with: | ||
| github_token: ${{ secrets.GITHUB_TOKEN }} | ||
| # Optional tuning: | ||
| # labels: "auto" # compare within matching labels, or "bug,api" |
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,41 @@ | ||
| name: Welcome New Contributors | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [opened] | ||
|
|
||
| permissions: | ||
| pull-requests: write | ||
| models: read | ||
|
|
||
| jobs: | ||
| welcome: | ||
| runs-on: ubuntu-latest | ||
| if: github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR' | ||
| steps: | ||
| - name: Generate welcome message | ||
| uses: actions/ai-inference@v1 | ||
| id: ai | ||
| with: | ||
| prompt: | | ||
| Write a friendly welcome message for a first-time contributor. Include: | ||
| 1. Thank them for their first PR | ||
| 2. Mention checking CONTRIBUTING.md | ||
| 3. Explain that after fixing 5 bugs, they can work on adding features | ||
| 4. Link to the welcome document: https://github.com/commons-app/commons-app-documentation/blob/master/android/Volunteers-welcome!.md | ||
| 5. Offer to help if they have questions | ||
|
|
||
| Keep it brief and encouraging. | ||
| model: openai/gpt-4o-mini | ||
|
|
||
| - name: Post welcome comment | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| const message = `${{ steps.ai.outputs.response }}`; | ||
| await github.rest.issues.createComment({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: ${{ github.event.pull_request.number }}, | ||
| body: message | ||
| }); |
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.
Sorry: do we first check whether the issue is assigned already? Sometimes a volunteer asks to be assigned to an issue that has already be assigned to someone else a few hours ago. In such cases we kindly ask them to find another bug and give them the issue search link found in the Welcome page. It would be fantastic to automate that. 🙂