name: Add label on auto-merge enabled
permissions:
    pull-requests: write
on:
    pull_request_target:
        types:
            - auto_merge_enabled
jobs:
    add-label-on-auto-merge:
        runs-on: ubuntu-latest
        steps:
            -   name: Add label
                uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
                with:
                    script: |
                        github.rest.issues.addLabels({
                            owner: context.repo.owner,
                            repo: context.repo.repo,
                            issue_number: context.issue.number,
                            labels: ['ready']
                        })
                env:
                    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
