name: vouch-manage-by-issue

on:
  issue_comment:
    types: [created]

concurrency:
  group: vouch-manage
  cancel-in-progress: false

permissions:
  contents: write
  issues: write
  pull-requests: read

jobs:
  manage:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          persist-credentials: false
          fetch-depth: 0

      - name: Setup git committer
        id: committer
        uses: ./.github/actions/setup-git-committer
        with:
          opencode-app-id: ${{ vars.OPENCODE_APP_ID }}
          opencode-app-secret: ${{ secrets.OPENCODE_APP_SECRET }}

      - uses: mitchellh/vouch/action/manage-by-issue@main
        with:
          issue-id: ${{ github.event.issue.number }}
          comment-id: ${{ github.event.comment.id }}
          roles: admin,maintain,write
        env:
          GITHUB_TOKEN: ${{ steps.committer.outputs.token }}
