Skip to content

Commit

Permalink
create pr for random update (#311)
Browse files Browse the repository at this point in the history
Co-authored-by: github-actions <[email protected]>
Co-authored-by: Naka Masato <[email protected]>
  • Loading branch information
3 people authored Nov 8, 2022
1 parent e08914a commit 3bbf0e8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
17 changes: 10 additions & 7 deletions .github/workflows/create-pr-when-pr-is-merged.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ jobs:
id: need_commit
run: |
if [[ -n "$(git status --porcelain)" ]]; then
echo "::set-output name=need_commit::true
echo "need_commit=true" >> "$GITHUB_OUTPUT"
else
echo "::set-output name=need_commit::false
echo "need_commit=false" >> "$GITHUB_OUTPUT"
fi
- name: commit and push
Expand All @@ -50,7 +50,7 @@ jobs:
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} # used by gh
run: |
echo "::set-output name=count::$(gh pr list -S head:${{ env.BRANCH_NAME }} -B ${{ env.BASE_BRANCH_NAME }} | wc -l)"
echo "count=$(gh pr list -S head:${{ env.BRANCH_NAME }} -B ${{ env.BASE_BRANCH_NAME }} | wc -l)" >> "$GITHUB_OUTPUT"
- name: create pr
if: ${{ steps.need_commit.outputs.need_commit == 'true' && steps.check_pr.outputs.count == 0 }}
Expand All @@ -73,14 +73,17 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: get pull request number
id: get_pr_number
run: |
echo ${{ fromJson(steps.create_pr.outputs.data).number }}
if [[ ${{ steps.check_pr.outputs.count }} = 0 ]]; then
echo "pr_number=${{ fromJson(steps.create_pr.outputs.data).number }}" >> "$GITHUB_OUTPUT"
fi
- name: request reviwer
if: ${{ steps.need_commit.outputs.need_commit == 'true' && steps.check_pr.outputs.count == 0 }}
if: steps.get_pr_number.outputs.pr_number != ""
uses: octokit/[email protected]
with:
route: POST /repos/${{ github.repository }}/pulls/${{ fromJson(steps.create_pr.outputs.data).number }}/requested_reviewers
reviewers: "[\"nakamasato\"]"
route: POST /repos/${{ github.repository }}/pulls/${{ steps.get_pr_number.outputs.pr_number }}/requested_reviewers
reviewers: "[\"${{ github.actor }}\"]" # the person who merges the pr
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# github-actions-practice

- Last Updated: 2022-11-04
- Last Merged PR: #309
- Last Merged PR: #310

## Github Actions Table

Expand Down

0 comments on commit 3bbf0e8

Please sign in to comment.