name: Danger
on:
  pull_request_target:
    types: [opened, edited, reopened, synchronize]

permissions:
  checks: write
  pull-requests: write
  statuses: write

jobs:
  danger:
    runs-on: ubuntu-latest
    if: github.actor != 'dependabot[bot]'
    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Setup
        uses: ./.github/actions/setup
        with:
          node-version: 16

      - name: Danger
        run: npm run danger ci
        env:
          # https://github.com/gatsbyjs/gatsby/pull/11555
          NODE_ENV: test
          GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
