-
Notifications
You must be signed in to change notification settings - Fork 1
73 lines (69 loc) · 2.4 KB
/
net80-dotnet-format.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-format
name: .NET 8.0 dotnet-format
on:
# pushトリガーだと `context.head_ref` が取得できない
# push:
# branches:
# - main
# paths:
# - 'dotnet/net8.0/**'
pull_request:
branches:
- main
paths:
- 'dotnet/net8.0/**'
workflow_dispatch:
env:
DOTNET_FORMAT_VERBOSITY: diag
BASE_BRANCH: ${{ github.head_ref }}
HEAD_BRANCH: dotnet-format-${{ github.run_id }}
permissions:
contents: write
pull-requests: write
jobs:
run-dotnet-format:
runs-on: ubuntu-latest
defaults:
run:
working-directory: 'dotnet/net8.0'
outputs:
base-branch-name: ${{ steps.commit-step.outputs.base-branch-name }}
head-branch-name: ${{ steps.commit-step.outputs.head-branch-name }}
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.0.x'
dotnet-quality: 'preview'
- name: Format on branch
id: commit-step
run: |
dotnet format consoleapp/consoleapp.csproj --no-restore --verbosity $DOTNET_FORMAT_VERBOSITY
# dotnet format razorpageapp/razorpageapp.csproj --no-restore --verbosity $DOTNET_FORMAT_VERBOSITY
git checkout -b $HEAD_BRANCH
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
git add .
git commit -m "[bot] Auto formatted"
git push --set-upstream origin $HEAD_BRANCH
# git checkout main
echo "base-branch-name: $BASE_BRANCH"
echo "base-branch-name=$BASE_BRANCH" >> $GITHUB_OUTPUT
echo "head-branch-name: $HEAD_BRANCH"
echo "head-branch-name=$HEAD_BRANCH" >> $GITHUB_OUTPUT
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
call-pull-request-workflow:
name: Call pull request workflow
needs: run-dotnet-format
uses: ./.github/workflows/github-pull-request-creation.yml
with:
base-branch-name: ${{ needs.run-dotnet-format.outputs.base-branch-name }}
head-branch-name: ${{ needs.run-dotnet-format.outputs.head-branch-name }}
show-pull-request-url:
name: Show pull request url
needs: call-pull-request-workflow
runs-on: ubuntu-latest
steps:
- run: echo ${{ needs.call-pull-request-workflow.outputs.pull-request-url }}