diff --git a/.github/workflows/danger.yml b/.github/workflows/danger.yml new file mode 100644 index 0000000..90cdbe9 --- /dev/null +++ b/.github/workflows/danger.yml @@ -0,0 +1,16 @@ +name: Danger +on: + pull_request: + branches: [ main ] +jobs: + danger: + name: Danger + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Danger + uses: docker://ghcr.io/danger/danger-swift:3.12.2 + with: + args: --failOnErrors --no-publish-check + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/Dangerfile.swift b/Dangerfile.swift new file mode 100644 index 0000000..c5e6345 --- /dev/null +++ b/Dangerfile.swift @@ -0,0 +1,20 @@ +import Danger +let danger = Danger() + +// Thanks other people! +if let github = danger.github { + let submitter = github.pullRequest.user.login + if submitter != "phatblat" && submitter != "chris-araman" { + danger.message(":tada: Thanks for your contribution, \(submitter)!") + } + + // Mainly to encourage writing up some reasoning about the PR, rather than just leaving a title + if github.pullRequest.body?.count ?? 0 < 5 { + danger.fail(":memo: Please provide a summary in the Pull Request description.") + } + + // Make it more obvious that a PR is a work in progress and shouldn't be merged yet + if github.pullRequest.title.contains("[WIP]") { + danger.warn(":construction: Title includes `[WIP]`. Please convert the pull request to a Draft.") + } +}