name: Project Automations

on:
  issues:
    types:
      - opened
      - reopened
  pull_request_target: #_target allows access to secrets
    types:
      - opened
      - reopened
    branches:
      - main
      - dev

env:
  todo: Todo
  done: Done
  in_progress: In Progress

jobs:
  issue_opened_or_reopened:
    name: issue_opened_or_reopened
    runs-on: ubuntu-latest
    if: github.event_name == 'issues' && (github.event.action == 'opened' || github.event.action == 'reopened')
    steps:
      - name: Set issue status to ${{ env.todo }}
        uses: leonsteinhaeuser/project-beta-automations@v1.2.1
        with:
          gh_token: ${{ secrets.GH_TOKEN }}
          organization: paperless-ngx
          project_id: 2
          resource_node_id: ${{ github.event.issue.node_id }}
          status_value: ${{ env.todo }} # Target status
  pr_opened_or_reopened:
    name: pr_opened_or_reopened
    runs-on: ubuntu-latest
    if: github.event_name == 'pull_request_target' && (github.event.action == 'opened' || github.event.action == 'reopened')
    steps:
      - name: Set PR status to ${{ env.in_progress }}
        uses: leonsteinhaeuser/project-beta-automations@v1.2.1
        with:
          gh_token: ${{ secrets.GH_TOKEN }}
          organization: paperless-ngx
          project_id: 2
          resource_node_id: ${{ github.event.pull_request.node_id }}
          status_value: ${{ env.in_progress }} # Target status