diff --git a/.github/workflows/create-pr-when-pr-is-merged.yml b/.github/workflows/create-pr-when-pr-is-merged.yml index 058b8df2..f5dc6dc3 100644 --- a/.github/workflows/create-pr-when-pr-is-merged.yml +++ b/.github/workflows/create-pr-when-pr-is-merged.yml @@ -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 @@ -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 }} @@ -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/request-action@v2.x 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 }} diff --git a/README.md b/README.md index 86a7c336..8321eb82 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # github-actions-practice - Last Updated: 2022-11-04 -- Last Merged PR: #309 +- Last Merged PR: #310 ## Github Actions Table