Skip to content

Instantly share code, notes, and snippets.

@egil
Forked from rickyah/dotnet-format-action.yml
Created July 27, 2020 08:42
Show Gist options
  • Save egil/fccf31406569bf6f10008c4d8cd32716 to your computer and use it in GitHub Desktop.
Save egil/fccf31406569bf6f10008c4d8cd32716 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