From 0e35ac7cacbe9e90a64e4a0e4237fed749080bbe Mon Sep 17 00:00:00 2001 From: Chris Araman Date: Thu, 18 Nov 2021 13:50:25 -0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A7=20Use=20Danger=20Swift=20GitHub=20?= =?UTF-8?q?Action?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/danger.yml | 16 ++++++++++++++++ Dangerfile.swift | 20 ++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 .github/workflows/danger.yml create mode 100644 Dangerfile.swift 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.") + } +}