diff --git a/.github/workflows/pull_requests.yml b/.github/workflows/pull_requests.yml index 3001a0a..7cbfce6 100644 --- a/.github/workflows/pull_requests.yml +++ b/.github/workflows/pull_requests.yml @@ -30,3 +30,24 @@ jobs: uses: ad-m/github-push-action@v0.6.0 with: github_token: ${{ secrets.GITHUB_TOKEN }} + run-danger: + runs-on: ubuntu-latest + if: "!contains(github.event.head_commit.message, '[skip ci]')" + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 13 + - name: Set up Ruby 3.1.2 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.1.2 + - name: Install and run awesome_bot + # It's okay for awesome_bot to fail. Danger will post a comment on the PR if it fails. + run: | + gem install awesome_bot + awesome_bot --allow 429 --allow-redirect --allow-dupe --allow-ssl -w ipfs.io README.md || echo + - name: Run danger + run: npx --yes danger ci + env: + DANGER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/dangerfile.js b/dangerfile.js new file mode 100644 index 0000000..326b12a --- /dev/null +++ b/dangerfile.js @@ -0,0 +1,33 @@ +const { danger, markdown, fail, warn, message } = require('danger') +const awesomeBotResults = require('./ab-results-README.md-markdown-table.json') + +// declare const danger: DangerDSLType +// declare function warn(message: string, file?: string, line?: number): void +// declare function fail(params: string): void +// declare function message(message: string): void + +// This is a simple example of a Dangerfile. +// You can run this Dangerfile via `danger pr + +const docs = danger.git.fileMatch('**/*.md') +const app = danger.git.fileMatch('src/**/*.ts') +const tests = danger.git.fileMatch('*/__tests__/*') +const yamlData = danger.git.fileMatch('data/**') +// const awesome_bot = danger.git.fileMatch('ab-results-README.md-markdown-table.json') + +if (awesomeBotResults.error) { + fail(awesomeBotResults.title) + markdown(awesomeBotResults.message) +} + +if (yamlData.edited) { + message('YAML data files were edited') +} + +if (docs.edited) { + message('Thanks - We :heart: our [documentarians](http://www.writethedocs.org/)!') +} + +if (app.modified && !tests.modified) { + warn('You have app changes without tests.') +}