Skip to content

Commit

Permalink
update net80-dotnet-format.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
tsubakimoto authored Jul 30, 2023
1 parent 7495154 commit 680f895
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 20 deletions.
23 changes: 15 additions & 8 deletions .github/workflows/github-pull-request-creation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ name: GitHub pull request creation
on:
workflow_call:
inputs:
branch-name:
description: "Branch name"
base-branch-name:
description: "Base branch name"
required: true
type: string
head-branch-name:
description: "Head branch name"
required: true
type: string
outputs:
Expand All @@ -13,8 +17,9 @@ on:
value: ${{ jobs.create-pull-request.outputs.pull-request-url }}

env:
BRANCH: ${{ inputs.branch-name }}
TITLE: "PR from ${{ inputs.branch-name }}"
BASE_BRANCH: ${{ inputs.base-branch-name }}
HEAD_BRANCH: ${{ inputs.head-branch-name }}
TITLE: "PR from ${{ inputs.head-branch-name }} to ${{ inputs.base-branch-name }}"

jobs:
create-pull-request:
Expand All @@ -26,16 +31,18 @@ jobs:
uses: actions/checkout@v3
- name: Dump parameters
run: |
echo "**branch name**"
echo "$BRANCH"
echo "**base branch name**"
echo "$BASE_BRANCH"
echo "**head branch name**"
echo "$HEAD_BRANCH"
echo "**title**"
echo $TITLE
- name: Create a pull request
id: pr
run: |
url=$(gh pr create \
--base main \
--head $BRANCH \
--base $BASE_BRANCH \
--head $HEAD_BRANCH \
--title "$TITLE" \
--body "")
echo "url=$url" >> $GITHUB_OUTPUT
Expand Down
30 changes: 18 additions & 12 deletions .github/workflows/net80-dotnet-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
name: .NET 8.0 dotnet-format

on:
push:
branches:
- main
paths:
- 'dotnet/net8.0/**'
# pushトリガーだと `context.head_ref` が取得できない
# push:
# branches:
# - main
# paths:
# - 'dotnet/net8.0/**'
pull_request:
branches:
- main
Expand All @@ -16,7 +17,8 @@ on:

env:
DOTNET_FORMAT_VERBOSITY: diag
BRANCH: dotnet-format-${{ github.run_id }}
BASE_BRANCH: ${{ context.head_ref }}
HEAD_BRANCH: dotnet-format-${{ github.run_id }}

permissions:
contents: write
Expand All @@ -29,7 +31,8 @@ jobs:
run:
working-directory: 'dotnet/net8.0'
outputs:
branch-name: ${{ steps.commit-step.outputs.branch-name }}
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
Expand All @@ -42,23 +45,26 @@ jobs:
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 $BRANCH
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 $BRANCH
git push --set-upstream origin $HEAD_BRANCH
# git checkout main
echo "branch-name: $BRANCH"
echo "branch-name=$BRANCH" >> $GITHUB_OUTPUT
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:
branch-name: ${{ needs.run-dotnet-format.outputs.branch-name }}
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
Expand Down

0 comments on commit 680f895

Please sign in to comment.