How to add dotnet code format bot to GitLab?

Viewed 208

How to automatically run the code format bot with dotnet format command, and create a new merge request when any code be modified.

As we know, we can add the .gitlab-ci.yml file to run the command in GitLab Runner. Any tools can help us to do it?

1 Answers

The open source tool: dotnetCampus.GitLabCodeFormatBot

Add the code to .gitlab-ci.yml file.

stages:
  - build

FormatCode:
  # Format rules by .editorconfig file
  stage: build
  script:
    - "dotnet tool update -g dotnetCampus.GitLabCodeFormatBot"
    - "AutomateFormatCodeAndCreateGitLabMergeRequest -Token Your_GitLab_Token"
  only:
    - dev
Related