Skip to content

Fix check scope 6588 #75

Fix check scope 6588

Fix check scope 6588 #75

name: Check Pull Request Scope
on:
pull_request:
types: [opened, synchronize]
permissions:
contents: read
issues: write
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:
model: openai/gpt-4o-mini
temperature: 0
max-tokens: 10
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.
Definitions:
- "Related changes" are modifications that all contribute to solving a single issue, bug fix, or feature request.
- "Unrelated changes" are modifications that could be cleanly split into separate pull requests without affecting each other or the main fix.
Examples of unrelated changes:
* Fixing indentation or formatting in unrelated files or in unrelated parts of a file.
* Adding or removing unrelated comments.
* Refactoring code in modules unrelated to the described issue/feature.
* Mixing UI changes with unrelated backend or configuration changes.
* Updating dependencies or libraries that are not directly related to the issue/feature being addressed.
Examples of related changes:
* Fixing multiple bugs that are part of the same feature or module.
* Implementing a feature that requires changes across multiple files or components.
* Refactoring code that is directly related to the issue being fixed.
Now, based on the title and description of the pull request below, determine if it contains unrelated changes.
Pull Request Title: ${{ github.event.pull_request.title }}
Pull Request Description: ${{ github.event.pull_request.body }}
Question:
Does this pull request appear to mix unrelated changes?
Your entire response MUST be exactly one of the following tokens:
- yes
- no
Requirements:
* Use lowercase only.
* No punctuation.
* No explanations.
* No additional text.
# 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."
});