# cSpell:words dessant
name: Lock Threads

on:
  schedule:
    - cron: '0 0 * * *'
  workflow_dispatch:

permissions: {}

concurrency:
  group: lock-threads

jobs:
  lock:
    runs-on: ubuntu-latest
    permissions:
      issues: write
      pull-requests: write
    if: github.repository_owner == 'better-auth'
    steps:
      - name: Generate App Token
        id: app-token
        uses: actions/create-github-app-token@f8d387b68d61c58ab83c6c016672934102569859 # v3.0.0
        if: vars.RELEASE_APP_ID != ''
        with:
          app-id: ${{ vars.RELEASE_APP_ID }}
          private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}

      - uses: dessant/lock-threads@7266a7ce5c1df01b1c6db85bf8cd86c737dadbe7 # v6.0.0
        with:
          github-token: ${{ steps.app-token.outputs.token || secrets.GITHUB_TOKEN }}
          process-only: 'issues, prs'
          issue-inactive-days: 7
          pr-inactive-days: 7
          add-issue-labels: 'locked'
          add-pr-labels: 'locked'
          issue-comment: >
            This issue has been locked as it was closed more than 7 days ago.
            If you're experiencing a similar problem or you have additional context,
            please open a new issue and reference this one.
          pr-comment: >
            This pull request has been locked as it was closed more than 7 days ago.
            If these changes are still relevant or you have additional context,
            please open a new PR and reference this one.
          log-output: true
