-
Notifications
You must be signed in to change notification settings - Fork 4
49 lines (42 loc) · 1.48 KB
/
quality.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
name: Format check
on:
pull_request:
types: [opened, reopened, edited, synchronize, ready_for_review]
jobs:
dotnet-format:
runs-on: ubuntu-latest
permissions:
contents: write
actions: write
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore ./csharp-minitwit/csharp-minitwit.sln
- name: Format
run: dotnet format ./csharp-minitwit/csharp-minitwit.sln --verbosity diagnostic
- name: Lint Dockerfile
uses: hadolint/hadolint-action@master
with:
dockerfile: ./csharp-minitwit/Dockerfile
- name: Lint C# code
run: dotnet build ./csharp-minitwit/csharp-minitwit.sln
- name: Push changes
run: |
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
git fetch --all
git checkout -b ${{ github.head_ref }} origin/${{ github.head_ref }}
git add .
# Check if there are any changes to commit
if git diff --staged --quiet; then
echo "No changes to commit."
else
git commit -am "Automated formatting"
git push
fi