name: "PR: Welcome Comment"
run-name: "PR: Welcome Comment #${{ github.event.pull_request.number }}"

on:
  pull_request:
    types: [opened]

jobs:
  welcome-comment:
    runs-on: ubuntu-latest
    steps:
      - name: Post available commands
        uses: actions/github-script@v7
        with:
          script: |
            await github.rest.issues.createComment({
              owner: context.repo.owner,
              repo: context.repo.repo,
              issue_number: context.payload.pull_request.number,
              body: [
                '👋 **Available commands for this PR:**',
                '',
                '| Command | Description |',
                '|---------|-------------|',
                '| `/preview` | Deploy a preview of the management UI |',
                '| `/preview-down` | Tear down the preview environment |',
                '',
                'You can also add the `preview` label to trigger a preview deploy.',
                '',
                'Preview environments are automatically cleaned up when the PR is closed or merged, and after 48 hours of inactivity.',
              ].join('\n'),
            });
