---
name: Auto Assign Issue to New Project

'on':
  issues:
    types: [opened]

jobs:
  add_issue:
    runs-on: ubuntu-latest
    steps:
      - name: Add Issue to New Front End Project Board
        env:
          GITHUB_TOKEN: ${{ secrets.GH_NEW_CARD_TO_PROJECT }}
          PROJECT_ID: ${{ secrets.FRONT_END_PROJECT_ID }}
          ISSUE_ID: ${{ github.event.issue.node_id }}
        run: |
          gh api graphql -f query='
            mutation($project:ID!, $issue:ID!) {
              addProjectNextItem(input: {projectId: $project, contentId: $issue}) {
                projectNextItem {
                  id
                }
              }
            }' -f project=$PROJECT_ID -f issue=$ISSUE_ID --jq '.data.addProjectNextItem.projectNextItem.id'
