Skip to content

Commit

Permalink
feat(ci): Added Danger
Browse files Browse the repository at this point in the history
  • Loading branch information
BirknerAlex committed Apr 11, 2024
1 parent 58555a1 commit 700e7b2
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/danger.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Danger

on:
pull_request:
branches:
- '*'

jobs:
danger:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: '2.6'
- uses: MeilCli/danger-action@v6
with:
danger_file: 'Dangerfile'
danger_id: 'danger-pr'
env:
DANGER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26 changes: 26 additions & 0 deletions Dangerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Ensure commit_subjection matches the following format
#
# fix(api): Caught Promise exception
# feat(panel): Added new files
# chore(docs): Updated dependencies
# refactor(api): Updated code to use new API
# test(api): Added new tests
# docs(monitoring): Updated documentation
# style(panel): Fixed linting issues
# perf(monitoring): Improved performance
allowed_types = %w(fix feat chore refactor test docs style perf)

git.commits.each do |commit|
commit_subject = commit.message.split("\n").first

if commit_subject.match?(/\.$/)
failure "The commit message \"#{commit_subject}\" does have a dot at the end. Please remove it"
end

unless commit_subject.match?(/^(fix|feat|chore|refactor|test|docs|style|perf)\([a-z0-9\-]+\): .+/)
failure "The commit subject \"#{commit_subject}\" does not match our guidelines. Example \"chore(api): Upgraded dependencies\", allowed types are #{allowed_types.join(", ")}"
end
end



0 comments on commit 700e7b2

Please sign in to comment.