
name: Auto Assign to Project(s)

on:
  issues:
    types: [opened, edited, milestoned]

permissions:
  contents: read

jobs:
  assign_one_project:
    runs-on: ubuntu-latest
    name: Assign milestoned to Project
    steps:
    - name: Get token
      id: get_token
      uses: actions/create-github-app-token@v2
      with:
        app-id: ${{ secrets.OBS_AUTOMATION_APP_ID }}
        private-key: ${{ secrets.OBS_AUTOMATION_APP_PEM }}
        permission-organization-projects: write
        permission-issues: read
    - name: Assign issues with milestones to project
      uses: elastic/assign-one-project-github-action@1.2.2
      if: github.event.issue && github.event.issue.milestone
      with:
        project: 'https://github.com/orgs/elastic/projects/454'
        project_id: '5882982'
        column_name: 'Planned'
      env:
        MY_GITHUB_TOKEN: ${{ steps.get_token.outputs.token }}
