feat: use danger to post awesome_bot results on PRs

This commit is contained in:
Russell Dempsey 2022-09-13 18:54:30 -07:00
parent 6949c82863
commit 01d4e7f471
2 changed files with 54 additions and 0 deletions

View File

@ -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 }}

33
dangerfile.js Normal file
View File

@ -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.')
}