How to setup Danger JS with GitHub Actions
Make sure you add danger as a devDependency:
1yarn add danger -D
A dangerfile.js
in the root directory. Example:
1// Add a CHANGELOG entry for app changes2const hasChangelog = danger.git.modified_files.includes("changelog.md");3const isTrivial = (danger.github.pr.body + danger.github.pr.title).includes(4 "#trivial"5);67if (!hasChangelog && !isTrivial) {8 warn("Please add a changelog entry for your changes.");9}
Lastly, create a workflow file at .github/workflow/
and give it any name, example: cy.yml
:
1name: CI Pull Requests23on:4 pull_request:5 branches: [master]67jobs:8 build:9 runs-on: ubuntu-latest10 steps:11 - uses: actions/checkout@master12 - name: Use Node.js 12.x13 uses: actions/setup-node@master14 with:15 node-version: 12.x1617 - name: yarn install18 run: yarn install1920 - name: Danger21 run: yarn danger ci22 env:23 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}