on:
  issue_comment:
    types:
      - created
jobs:
  danger-for-external:
    name: Danger for external - Node.js 16
    if: |
      github.event_name == 'issue_comment' && github.event.action == 'created'
      && github.event.issue.pull_request != null
      && startsWith(github.event.comment.body, '/danger')
    runs-on: ubuntu-latest
    steps:
    - name: Check repository permission for user
      uses: sushichop/action-repository-permission@v2
      with:
        required-permission: write
        reaction-permitted: rocket
        comment-not-permitted: Sorry, you don't have enough permission to execute `/danger`...
    - name: Clone the PR source
      uses: actions/checkout@v3
      with:
        ref: refs/pull/${{ github.event.issue.number }}/head
        fetch-depth: 0
    - uses: actions/setup-node@v3
      with:
        node-version: 16
    - name: Danger JS
      run: npx danger ci
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
