name: "When Opened"

on:
  issues:
    types:
    - opened
  # pull_request_target is only dangerous if combined with an explicit checkout
  # of the opener's code, which it isn't here. See
  # https://securitylab.github.com/resources/github-actions-preventing-pwn-requests/
  pull_request_target: # zizmor: ignore[dangerous-triggers]
    types:
    - opened

permissions:
  pull-requests: write

jobs:
  triage:
    runs-on: ubuntu-latest
    steps:
    - name: Label PR
      uses: actions/labeler@634933edcd8ababfe52f92936142cc22ac488b1b  # v6.0.1
      if: |
        github.event_name == 'pull_request_target' &&
        github.event.pull_request.user.login != 'meeseeksmachine'
      with:
        repo-token: "${{ secrets.GITHUB_TOKEN }}"
    - name: 'Reviewer Checklist'
      uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3  # v9.0.0
      if: github.event_name == 'pull_request_target'
      with:
        github-token: ${{ secrets.GITHUB_TOKEN }}
        script: |
          await github.rest.issues.createComment({
            issue_number: context.issue.number,
            owner: context.repo.owner,
            repo: context.repo.repo,
            body: `Thank you for your contribution to Astropy! 🌌 This checklist is meant to remind the package maintainers who will review this pull request of some common things to look for.

            - [ ] Do the proposed changes actually accomplish desired goals?
            - [ ] Do the proposed changes follow the [Astropy coding guidelines](https://docs.astropy.org/en/latest/development/codeguide.html)?
            - [ ] Are tests added/updated as required? If so, do they follow the [Astropy testing guidelines](https://docs.astropy.org/en/latest/development/testguide.html)?
            - [ ] Are docs added/updated as required? If so, do they follow the [Astropy documentation guidelines](https://docs.astropy.org/en/latest/development/docguide.html)?
            - [ ] Is rebase and/or squash necessary? If so, please provide the author with appropriate instructions. Also see instructions for [rebase](https://docs.astropy.org/en/latest/development/development_details.html#rebase-if-necessary) and [squash](https://docs.astropy.org/en/latest/development/development_details.html#squash-if-necessary).
            - [ ] Did the CI pass? If no, are the failures related? If you need to run daily and weekly cron jobs as part of the PR, please apply the "Extra CI" label. Codestyle issues can be fixed by the [bot](https://docs.astropy.org/en/latest/development/development_details.html#pre-commit).
            - [ ] Is a change log needed? If yes, did the change log check pass? If no, add the "no-changelog-entry-needed" label. If this is a manual backport, use the "skip-changelog-checks" label unless special changelog handling is necessary.
            - [ ] Is this a big PR that makes a "What's new?" entry worthwhile and if so, is (1) a "what's new" entry included in this PR and (2) the "whatsnew-needed" label applied?
            - [ ] At the time of adding the milestone, if the milestone set requires a backport to release branch(es), apply the appropriate "backport-X.Y.x" label(s) *before* merge.`
          })
    # Special action for a special day. Until next year!
    #- name: Special comment
    #  uses: pllim/action-special_pr_comment@5126c189c02418a55448480b28efd1a00af48d7b  # 0.2
    #  with:
    #    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
