gh pr comment --edit-last --create-if-none
TL;DR
# before
- name: Add Commnet to Pull Request
run: gh pr comment ${{ github.ref_name }} --body "${{ env.GH_SAMPLE_COMMENT }}" --edit-last || gh pr comment ${{ github.ref_name }} --body "${{ env.GH_SAMPLE_COMMENT }}"
# after
- name: Add Commnet to Pull Request
run: gh pr comment ${{ github.ref_name }} --body "${{ env.GH_SAMPLE_COMMENT }}" --edit-last --create-if-none
詳細
GitHub Actions で Pull Request にコメントをつける で前に紹介した、 --edit-last
というオプションについに --create-if-none
が追加されました。
$ gh pr comment -help
Add a comment to a GitHub pull request.
Without the body text supplied through flags, the command will interactively
prompt for the comment text.
USAGE
gh pr comment [<number> | <url> | <branch>] [flags]
FLAGS
-b, --body text The comment body text
-F, --body-file file Read body text from file (use "-" to read from standard input)
--create-if-none Create a new comment if no comments are found. Can be used only with --edit-last
--edit-last Edit the last comment of the same author
-e, --editor Skip prompts and open the text editor to write the body in
-w, --web Open the web browser to write the comment
INHERITED FLAGS
--help Show help for command
-R, --repo [HOST/]OWNER/REPO Select another repository using the [HOST/]OWNER/REPO format
EXAMPLES
$ gh pr comment 13 --body "Hi from GitHub CLI"
LEARN MORE
Use `gh <command> <subcommand> --help` for more information about a command.
Read the manual at https://cli.github.com/manual
Learn about exit codes using `gh help exit-codes`
- name: Add Commnet to Pull Request
run: gh pr comment ${{ github.ref_name }} --body "${{ env.GH_SAMPLE_COMMENT }}" --edit-last || gh pr comment ${{ github.ref_name }} --body "${{ env.GH_SAMPLE_COMMENT }}"
GitHub Actions で Pull Request にコメントをつける で紹介してた上記の書き方ではなく、以下のように書き直すことができるようになった。
- name: Add Commnet to Pull Request
run: gh pr comment ${{ github.ref_name }} --body "${{ env.GH_SAMPLE_COMMENT }}" --edit-last --create-if-none