name: Move new issues onto Issue triage board

on:
  issues:
    types: [opened]

jobs:
  automate-project-columns:
    runs-on: ubuntu-latest
    steps:
      - uses: alex-page/github-project-automation-plus@bb266ff4dde9242060e2d5418e120a133586d488
        with:
          project: Issue triage
          column: Incoming
          repo-token: ${{ secrets.ELEMENT_BOT_TOKEN }}

  add_to_triage:
    runs-on: ubuntu-latest
    if: >
      github.repository == 'element-hq/element-ios'
    steps:
      - uses: octokit/graphql-action@v2.x
        with:
          headers: '{"GraphQL-Features": "projects_next_graphql"}'
          query: |
            mutation add_to_project($projectid:ID!,$contentid:ID!) {
              addProjectV2ItemById(input: {projectId: $projectid contentId: $contentid}) {
                item {
                  id
                }
              }
            }
          projectid: ${{ env.PROJECT_ID }}
          contentid: ${{ github.event.issue.node_id }}
        env:
          PROJECT_ID: "PVT_kwDOAM0swc4AMlHr"
          GITHUB_TOKEN: ${{ secrets.ELEMENT_BOT_TOKEN }}
