Skip to content

Commit 44f7461

Browse files
Add Danger-bot
Signed-off-by: Tom Siewert <[email protected]>
1 parent 355c37e commit 44f7461

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed

.github/workflows/danger.yml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
name: Dangerbot
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
jobs:
9+
danger:
10+
name: Danger
11+
runs-on: self-hosted
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v3
15+
16+
- name: Setup Ruby 3.0
17+
uses: ruby/setup-ruby@v1
18+
with:
19+
ruby-version: '3.0'
20+
21+
- name: Configure cache
22+
uses: actions/cache@v1
23+
with:
24+
path: vendor/bundle
25+
key: ${{ runner.os }}-gems-${{ hashFiles('Gemfile') }}
26+
restore-keys: |
27+
${{ runner.os }}-gems-
28+
29+
- name: Run Danger
30+
uses: MeilCli/danger-action@v5
31+
with:
32+
plugins_file: 'Gemfile'
33+
install_path: 'vendor/bundle'
34+
danger_file: 'Dangerfile'
35+
danger_id: 'danger-pr'
36+
env:
37+
DANGER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Dangerfile

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# -*- mode: ruby -*- vim: set syntax=ruby
2+
# frozen_string_literal: true
3+
4+
if git.commits.any? { |c| c.message =~ /^Merge branch/ }
5+
fail('Please rebase to get rid of the merge commits in this PR!')
6+
message "For more information, please see [man git-rebase](https://git-scm.com/docs/git-rebase)."
7+
end
8+
9+
if !git.modified_files.include?("CHANGELOG.md") && !has_app_changes
10+
fail("Please include a CHANGELOG entry. \nYou can find it at [CHANGELOG.md](https://github.com/hetznercloud/ansible-ipxe-ca/blob/main/CHANGELOG.md).")
11+
message "Note, we use [changelogger](https://github.com/MarkusFreitag/changelogger) as changelog tooling."
12+
end

Gemfile

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# frozen_string_literal: true
2+
3+
source 'https://rubygems.org'
4+
5+
gem 'danger'

0 commit comments

Comments
 (0)