-
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
Changes from 1 commit
8a1560b
56d7239
069d4cd
b5ce6db
29e785b
31db879
9bcb579
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| 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 | ||
| temperature: 0.1 | ||
|
|
||
| - name: Handle assignment | ||
| if: steps.check-request.outputs.response == 'yes' | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| // Get all open issues assigned to the commenter | ||
| const assignedIssues = await github.rest.issues.listForRepo({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| assignee: context.actor, | ||
| state: 'open' | ||
| }); | ||
| // Get all open PRs created by the commenter | ||
| const pullRequests = await github.rest.pulls.list({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| creator: context.actor, | ||
| state: 'open' | ||
| }); | ||
| // No assigned issues - 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: assign them | ||
| else { | ||
| await github.rest.issues.addAssignees({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: context.issue.number, | ||
| assignees: [context.actor] | ||
| }); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| name: Check PR 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 PR mixes unrelated changes | ||
| - name: Analyze PR changes | ||
| uses: actions/ai-inference@v1 | ||
| id: analyze | ||
| with: | ||
| prompt: | | ||
| Analyze this pull request to determine if it contains unrelated changes. | ||
| A PR should contain logically separate commits for logically separate changes. | ||
nicolas-raoul marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| PR Title: ${{ github.event.pull_request.title }} | ||
| PR Description: ${{ github.event.pull_request.body }} | ||
|
|
||
| Does this PR appear to mix unrelated changes? Respond with only "yes" or "no". | ||
| model: openai/gpt-4o-mini | ||
| temperature: 0.1 | ||
| # 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 PR appears to contain unrelated changes. The guidelines state: 'Make separate commits for logically separate changes.' Please review [CONTRIBUTING.md](https://github.com/commons-app/apps-android-commons/blob/master/CONTRIBUTING.md) and consider splitting this into separate PRs." | ||
nicolas-raoul marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| }); | ||
| 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" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| 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 enhancements | ||
|
||
| 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 | ||
| temperature: 0.7 | ||
|
|
||
| - 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 | ||
| }); | ||
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. 🙂