A GitHub Action to automatically check and enforce C# code formatting using CSharpier. This action helps maintain clean code by running formatting checks and posting annotations, job summaries, and PR comments when issues are detected.
- Automatic formatting check: Uses
dotnet csharpier check .to validate the formatting of all C# files. - Job summary: Uploads a neat, easy-to-read summary in the GitHub Actions interface.
- Inline annotations: Adds warnings in the code where formatting is incorrect.
- PR comments: Posts a comment on the pull request with the list of issues detected.
You can use this action in your workflows by referencing it as a reusable workflow:
jobs:
linter-check:
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: CSharpier Linter
uses: guibranco/[email protected]- C# files should be part of your repository.
- Make sure your repository has
.csfiles,.csproj, or similar files that are relevant to the format.
- Job summary: Available in the PR Checks section, clearly summarizing the formatting issues.
- Annotations: Warning annotations are placed on the lines where formatting issues are found.
- PR Comments: An easy-to-read comment posted directly on the PR.
Hereβs an example workflow that uses this action:
name: Linter check
on:
workflow_dispatch:
pull_request:
jobs:
linter-check:
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: CSharpier Linter
uses: guibranco/[email protected]- Setup .NET: Ensures that .NET SDK is installed.
- Run CSharpier: Runs
dotnet csharpier check .and checks for any formatting issues. - Create Annotations and PR Comments: If issues are found, the action creates inline annotations, a job summary, and a comment on the PR.
To contribute to this action:
- Clone the repository and test locally.
- Make sure to follow best practices for creating GitHub Actions.
- Clone this repo to use in your own workflows.
- Feel free to open issues or submit pull requests to improve the action!
This project is licensed under the MIT License - see the LICENSE file for details.