diff --git a/.github/workflows/pull_requests.yml b/.github/workflows/pull_requests.yml index d3eba72..6e68577 100644 --- a/.github/workflows/pull_requests.yml +++ b/.github/workflows/pull_requests.yml @@ -37,10 +37,13 @@ jobs: github_token: ${{ secrets.GITHUB_TOKEN }} run-danger: runs-on: ubuntu-latest + needs: update-readme if: "!contains(github.event.head_commit.message, '[skip ci]')" steps: - name: Checkout uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.head.ref }} - name: Setup Node.js uses: actions/setup-node@v3 with: diff --git a/dangerfile.js b/dangerfile.js index 326b12a..1896377 100644 --- a/dangerfile.js +++ b/dangerfile.js @@ -1,33 +1,30 @@ 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 githubMetadata = danger.git.fileMatch('.github/**') const yamlData = danger.git.fileMatch('data/**') -// const awesome_bot = danger.git.fileMatch('ab-results-README.md-markdown-table.json') +const scripts = danger.git.fileMatch('scripts/**') +const src = danger.git.fileMatch('src/**') -if (awesomeBotResults.error) { - fail(awesomeBotResults.title) - markdown(awesomeBotResults.message) +if (githubMetadata.edited) { + message('Changes were made within the .github folder.') } if (yamlData.edited) { - message('YAML data files were edited') + message('YAML data files were edited.') + /** + * Only display awesomeBot results if the data yaml used to generate the readme have been modified. + */ + if (awesomeBotResults.error) { + fail(awesomeBotResults.title) + markdown(awesomeBotResults.message) + } } -if (docs.edited) { - message('Thanks - We :heart: our [documentarians](http://www.writethedocs.org/)!') +if (scripts.edited) { + warn('Changes were made to the scripts folder.') } -if (app.modified && !tests.modified) { - warn('You have app changes without tests.') +if (src.edited) { + warn('Changes were made to the src folder.') }