Skip to content

Commit e3d614a

Browse files
Create dotnet-format.yml
1 parent eb54b32 commit e3d614a

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

.github/workflows/dotnet-format.yml

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Code format check
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
jobs:
8+
dotnet-format:
9+
runs-on: windows-latest
10+
steps:
11+
12+
- name: Checkout repo
13+
uses: actions/checkout@v2
14+
with:
15+
ref: ${{ github.head_ref }}
16+
17+
- name: Install dotnetCampus.EncodingNormalior
18+
run: dotnet tool update -g dotnetCampus.EncodingNormalior
19+
20+
- name: Fix encoding
21+
run: EncodingNormalior -f . --TryFix true
22+
23+
- name: Install dotnet-format
24+
run: dotnet tool install -g dotnet-format
25+
26+
- name: Run dotnet format
27+
run: dotnet format
28+
29+
- name: Commit files
30+
run: |
31+
git config --local user.name "github-actions-dotnet-formatter[bot]"
32+
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
33+
git commit -a -m 'Automated dotnet-format update'
34+
continue-on-error: true
35+
36+
- name: Create Pull Request
37+
# if: steps.format.outputs.has-changes == 'true' # 如果有格式化,才继续
38+
uses: peter-evans/create-pull-request@v3
39+
with:
40+
title: '[Bot] Automated PR to fix formatting errors'
41+
body: |
42+
Automated PR to fix formatting errors
43+
committer: GitHub <[email protected]>
44+
author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
45+
# 以下是给定代码审查者,需要设置仓库有权限的开发者
46+
assignees: lindexi,walterlv
47+
reviewers: lindexi,walterlv
48+
# 对应的上传分支
49+
branch: t/bot/fix-codeformatting

0 commit comments

Comments
 (0)