Skip to content

Instantly share code, notes, and snippets.

@rickyah
Created July 25, 2020 08:24
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save rickyah/49974084804deb0726ffe718a99c2c23 to your computer and use it in GitHub Desktop.
Save rickyah/49974084804deb0726ffe718a99c2c23 to your computer and use it in GitHub Desktop.
Runs dotnet-format on every PR and create a commit that fixes the formatting if it doesn't comply with your code convention
name: Format check on pull request
on: pull_request
jobs:
dotnet-format:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v2.2.0
with:
fetch-depth: 0
ref: ${{ github.head_ref }}
- name: Install dotnet-format
run: dotnet tool install -g dotnet-format --version 3.3.111304
- name: Run dotnet format
id: format
uses: xt0rted/dotnet-format@v1.0.2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
action: "fix"
only-changed-files: true
folder: "."
- name: Commit files
if: steps.format.outputs.has-changes == 'true'
uses: EndBug/add-and-commit@v4.1.0
with:
author_name: Github Actions
author_email: actions@github.com
message: Automated dotnet-format update
ref: ${{ github.head_ref }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment