Update Class1.cs #14
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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.outputs.base-branch-name }} | |
head-branch-name: ${{ steps.commit.outputs.head-branch-name }} | |
changed: ${{ steps.verify-diff.outputs.changed }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: '8.0.x' | |
dotnet-quality: 'preview' | |
- name: Format | |
run: | | |
dotnet format consoleapp/consoleapp.csproj --no-restore --verbosity $DOTNET_FORMAT_VERBOSITY | |
# dotnet format razorpageapp/razorpageapp.csproj --no-restore --verbosity $DOTNET_FORMAT_VERBOSITY | |
- name: Check if there are any changes | |
id: verify-diff | |
run: | | |
git diff --quiet . || echo "changed=true" >> $GITHUB_OUTPUT | |
- name: Commit | |
if: steps.verify-diff.outputs.changed == 'true' | |
id: commit | |
run: | | |
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 $BASE_BRANCH | |
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 | |
if: needs.run-dotnet-format.outputs.changed == 'true' | |
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 }} |