Skip to content

Commit 5719d06

Browse files
authored
Merge pull request #21 from dotnet-campus/t/lindexi/ci
加上自动格式化工具
2 parents 3e3b552 + 13299a7 commit 5719d06

1 file changed

Lines changed: 52 additions & 0 deletions

File tree

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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+
# 代码文件编码规范机器人,详细请看 [dotnet 在 GitHub 的 Action 上部署自动代码编码规范机器人](https://blog.lindexi.com/post/dotnet-%E5%9C%A8-GitHub-%E7%9A%84-Action-%E4%B8%8A%E9%83%A8%E7%BD%B2%E8%87%AA%E5%8A%A8%E4%BB%A3%E7%A0%81%E7%BC%96%E7%A0%81%E8%A7%84%E8%8C%83%E6%9C%BA%E5%99%A8%E4%BA%BA.html)
18+
- name: Install dotnetCampus.EncodingNormalior
19+
run: dotnet tool update -g dotnetCampus.EncodingNormalior
20+
21+
- name: Fix encoding
22+
run: EncodingNormalior -f . --TryFix true
23+
24+
# 代码格式化机器人,详细请看 [dotnet 基于 dotnet format 的 GitHub Action 自动代码格式化机器人](https://blog.lindexi.com/post/dotnet-%E5%9F%BA%E4%BA%8E-dotnet-format-%E7%9A%84-GitHub-Action-%E8%87%AA%E5%8A%A8%E4%BB%A3%E7%A0%81%E6%A0%BC%E5%BC%8F%E5%8C%96%E6%9C%BA%E5%99%A8%E4%BA%BA.html )
25+
- name: Install dotnet-format
26+
run: dotnet tool install -g dotnet-format
27+
28+
- name: Run dotnet format
29+
run: dotnet format
30+
31+
- name: Commit files
32+
# 下面将使用机器人的账号,你可以替换为你自己的账号
33+
run: |
34+
git config --local user.name "github-actions-dotnet-formatter[bot]"
35+
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
36+
git commit -a -m 'Automated dotnet-format update'
37+
continue-on-error: true
38+
39+
- name: Create Pull Request
40+
# if: steps.format.outputs.has-changes == 'true' # 如果有格式化,才继续
41+
uses: peter-evans/create-pull-request@v3
42+
with:
43+
title: '[Bot] Automated PR to fix formatting errors'
44+
body: |
45+
Automated PR to fix formatting errors
46+
committer: GitHub <noreply@github.com>
47+
author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
48+
# 以下是给定代码审查者,需要设置仓库有权限的开发者
49+
assignees: lindexi,walterlv
50+
reviewers: lindexi,walterlv
51+
# 对应的上传分支
52+
branch: t/bot/fix-codeformatting

0 commit comments

Comments
 (0)