name: Assign Issue

on:
  schedule:
    - cron: 4 12 * * *
  issue_comment:
    types: [created]
  workflow_dispatch:

jobs:
  assign:
    if: github.repository_owner == 'JabRef'
    runs-on: ubuntu-latest
    permissions:
      issues: write
    steps:
      - name: Assign the user or unassign stale assignments
        id: assign
        uses: takanome-dev/assign-issue-action@beta
        with:
          github_token: '${{ secrets.GITHUB_TOKEN }}'
          days_until_unassign: 30
          maintainers: koppor, Siedlerchr, ThiloteE, calixtus, HoussemNasri
          assigned_comment: |
            👋 Hey @{{ handle }}, thank you for your interest in this issue! 🎉

            We're excited to have you on board. Start by exploring our [Contributing](https://github.com/JabRef/jabref/blob/main/CONTRIBUTING.md) guidelines, and don't forget to check out our [workspace setup guidelines](https://devdocs.jabref.org/getting-into-the-code/guidelines-for-setting-up-a-local-workspace) to get started smoothly.

            In case you encounter failing tests during development, please check our [developer FAQs](https://devdocs.jabref.org/code-howtos/faq.html)!

            Having any questions or issues? Feel free to ask here on GitHub. Need help setting up your local workspace? Join the conversation on [JabRef's Gitter chat](https://gitter.im/JabRef/jabref). And don't hesitate to open a (draft) pull request early on to show the direction it is heading towards. This way, you will receive valuable feedback.

            Happy coding! 🚀

            ⏳ Please note, you will be automatically unassigned if the issue isn't closed within **{{ total_days }} days** (by **{{ unassigned_date }}**). A maintainer can also add the "**{{ pin_label }}**"" label to prevent automatic unassignment.
      - name: Move Issue to "Assigned" Column in "Candidates for University Projects"
        if: steps.assign.outputs.assigned == 'yes'
        uses: m7kvqbe1/github-action-move-issues@feat/skip-if-not-in-project-flag
        with:
          github-token: ${{ secrets.GH_TOKEN_ACTION_MOVE_ISSUE }}
          project-url: "https://github.com/orgs/JabRef/projects/3"
          target-labels: "📍 Assigned"
          target-column: "Assigned"
          ignored-columns: ""
          default-column: "Free to take"
          skip-if-not-in-project: true
      - name: Move Issue to "Assigned" Column in "Good First Issues"
        if: steps.assign.outputs.assigned == 'yes'
        uses: m7kvqbe1/github-action-move-issues@feat/skip-if-not-in-project-flag
        with:
          github-token: ${{ secrets.GH_TOKEN_ACTION_MOVE_ISSUE }}
          project-url: "https://github.com/orgs/JabRef/projects/5"
          target-labels: "📍 Assigned"
          target-column: "Assigned"
          ignored-columns: ""
          default-column: "Free to take"
          skip-if-not-in-project: true