name: Move labelled issues to correct projects

on:
  issues:
    types: [ labeled ]

jobs:
  move_needs_info:
    runs-on: ubuntu-latest
    if: >
      contains(github.event.issue.labels.*.name, 'X-Needs-Info')
    permissions:
      contents: read
    env:
      # This token must have the following scopes: ["repo:public_repo", "admin:org->read:org", "user->read:user", "project"]
      GITHUB_TOKEN: ${{ secrets.ELEMENT_BOT_TOKEN }}
      PROJECT_OWNER: matrix-org
      # Backend issue triage board.
      # https://github.com/orgs/matrix-org/projects/67/views/1
      PROJECT_NUMBER: 67
      ISSUE_URL: ${{ github.event.issue.html_url }}
      # This field is case-sensitive.
      TARGET_STATUS: Needs info
    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
        with:
          # Only clone the script file we care about, instead of the whole repo.
          sparse-checkout: .ci/scripts/triage_labelled_issue.sh

      - name: Ensure issue exists on the board, then set Status
        run: .ci/scripts/triage_labelled_issue.sh
