name: Issue management - remove labels as needed

on:
  issue_comment:
    types: [created]

jobs:
  issue_comment:
    if: >
      contains(github.event.issue.labels.*.name, 'needs author feedback') &&
      github.event.comment.user.login == github.event.issue.user.login
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4

      - name: Remove labels
        env:
          ISSUE_NUMBER: ${{ github.event.issue.number }}
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          gh issue edit --remove-label "needs author feedback" $ISSUE_NUMBER
          gh issue edit --remove-label "stale" $ISSUE_NUMBER
