name: Closed Issue Update

on:
  issues:
    types: [closed]
permissions: {}

jobs:
  unlabel:
    runs-on: ubuntu-latest
    permissions:
      issues: write
    if: contains(toJson(github.event.issue.labels), 'needs-triage')
    steps:
    - uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
      with:
        script: |
          github.rest.issues.removeLabel({
            issue_number: context.issue.number,
            owner: context.repo.owner,
            repo: context.repo.repo,
            name: 'needs-triage'
          })      
  auto_comment:
    runs-on: ubuntu-latest
    permissions:
      issues: write
    steps:
    - uses: aws-actions/closed-issue-message@10aaf6366131b673a7c8b7742f8b3849f1d44f18 # v2
      with:
        # These inputs are both required
        repo-token: "${{ secrets.GITHUB_TOKEN }}"
        message: |
          This issue is now closed. Comments on closed issues are hard for our team to see. 
          If you need more assistance, please open a new issue that references this one.
