Feat: Add crop functionality to image editing with overlay support #352
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
| # Automated runs commented out, see https://github.com/commons-app/apps-android-commons/issues/6576#issuecomment-3618798882 | |
| # Added workflow_dispatch temporarily for having a syntactically correct workflow file | |
| on: | |
| issue_comment: | |
| types: [created] | |
| permissions: | |
| issues: write | |
| models: read | |
| concurrency: | |
| group: auto-assign-${{ github.event.issue.number || github.run_id }} | |
| cancel-in-progress: true | |
| jobs: | |
| auto-assign: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check if requesting assignment | |
| uses: actions/ai-inference@v1 | |
| id: check-request | |
| with: | |
| prompt: | | |
| You are a project management assistant. Determine if the user is explicitly asking to be assigned to THIS specific GitHub issue. | |
| ISSUE CONTEXT: | |
| Title: ${{ github.event.issue.title }} | |
| Description: ${{ github.event.issue.body }} | |
| USER COMMENT: | |
| "${{ github.event.comment.body }}" | |
| STRICT RULES: | |
| 1. Respond "yes" ONLY if the user wants to work on the task described in the ISSUE CONTEXT. | |
| 2. Respond "no" if the user is offering general help, suggesting new features, or discussing unrelated topics. | |
| 3. Respond "no" if the user is just answering a question or providing feedback. | |
| 4. If they say "I can help" but are talking about a different topic than the issue description, respond "no". | |
| Respond with only "yes" or "no". | |
| model: openai/gpt-4o-mini | |
| - name: Handle assignment | |
| if: steps.check-request.outputs.response == 'yes' | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const commenter = context.actor; | |
| const authorAssociation = context.payload.comment.author_association; | |
| const isFirstTime = authorAssociation === 'FIRST_TIME_CONTRIBUTOR' || authorAssociation === 'NONE'; | |
| const welcomeMessage = `\n\nSince you're new here, a huge welcome to the team! ❤️ Feel free to check out our welcome guide to get started: https://github.com/commons-app/commons-app-documentation/blob/master/android/Volunteers-welcome!.md`; | |
| // 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) { | |
| let body = `Hi @${commenter}! Thanks for reaching out. It looks like someone is already working on this one at the moment. `; | |
| body += `\n\nNo worries, though-there are plenty of other ways to help! You can find more open issues here: 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`; | |
| // Only show the welcome message to new contributors | |
| if (isFirstTime) body += welcomeMessage; | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| body: body | |
| }); | |
| return; | |
| } | |
| // Check commenter's existing assignments and PR's | |
| const assignedIssues = await github.rest.issues.listForRepo({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| assignee: commenter, | |
| state: 'open' | |
| }); | |
| const pullRequests = await github.rest.pulls.list({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| creator: commenter, | |
| state: 'open' | |
| }); | |
| // Decision logic: | |
| // - If no assigned issues: safe to assign | |
| // - If has assigned issues and has open PR: safe to assign (they are waiting for review) | |
| // - If has assigned issues but no pr's: block (they need to finish current work first) | |
| if (assignedIssues.data.length === 0 || pullRequests.data.length > 0) { | |
| await github.rest.issues.addAssignees({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| assignees: [commenter] | |
| }); | |
| // Post the confirmation comment | |
| let body = `Hi @${commenter}! You have been assigned to this issue. ✨`; | |
| if (isFirstTime) body += welcomeMessage; | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| body: body | |
| }); | |
| } else { | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| body: `Hi @${commenter}! It looks like you're already busy with another open task. To keep things moving and make sure everyone gets a chance to help out, we usually recommend wrapping up your current work before starting something new. \n\nOnce you've submitted a PR for your current task, we'd be happy to help you get started on this one! ✨` | |
| }); | |
| } |