Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions .github/workflows/auto_assign.yml
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: |
Copy link
Member

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. 🙂

// 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]
});
}
45 changes: 45 additions & 0 deletions .github/workflows/pull_request_unrelated_changes.yml
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."
});
24 changes: 24 additions & 0 deletions .github/workflows/suggest_duplicate_bug.yml
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"
41 changes: 41 additions & 0 deletions .github/workflows/welcome_new_contributors.yml
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
});