Skip to content

Commit 38c890a

Browse files
Create format.yml
1 parent 717e4b7 commit 38c890a

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

.github/workflows/format.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Format
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
dotnet_version:
7+
description: "The .NET SDK version to use"
8+
required: false
9+
default: "9.0.x"
10+
type: string
11+
secrets:
12+
GH_TOKEN:
13+
description: "GitHub token with write permissions"
14+
required: false
15+
16+
jobs:
17+
format:
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Checkout Code
22+
uses: actions/checkout@v4
23+
with:
24+
token: ${{ secrets.GH_TOKEN || github.token }}
25+
26+
- name: Setup .NET
27+
uses: actions/setup-dotnet@v4
28+
with:
29+
dotnet-version: ${{ inputs.dotnet_version }}
30+
31+
- name: Format Code
32+
run: dotnet format
33+
34+
- name: Commit & Push Updated Styles
35+
if: always()
36+
continue-on-error: true
37+
run: |
38+
git config --global user.name 'github-actions'
39+
git config --global user.email 'github-actions@github.com'
40+
git diff --quiet || (git commit -am "chore: format code with dotnet format" && git push)

0 commit comments

Comments
 (0)