You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -27,51 +57,74 @@ A GitHub action to create a comment for a commit on GitHub.
27
57
| `token` | `GITHUB_TOKEN` or a `repo` scoped [PAT](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token). | `GITHUB_TOKEN` |
28
58
| `repository` | The full name of the target repository. | `github.repository` (current repository) |
29
59
| `sha` | The commit SHA. | `github.sha` OR, for `pull_request` events `github.event.pull_request.head.sha` |
30
-
| `body` | (**required**) The contents of the comment. | |
31
60
| `path` | Relative path of the file to comment on. | |
32
61
| `position` | Line index in the diff to comment on. | |
62
+
| `comment-id` | The id of the comment to update. | |
63
+
| `body` | The comment body. Cannot be used in conjunction with `body-path`. | |
64
+
| `body-path` | The path to a file containing the comment body. Cannot be used in conjunction with `body`. | |
65
+
| `edit-mode` | The mode when updating a comment, `replace` or `append`. | `append` |
66
+
| `append-separator` | The separator to use when appending to an existing comment. (`newline`, `space`, `none`) | `newline` |
67
+
| `reactions` | A comma or newline separated list of reactions to add to the comment. (`+1`, `-1`, `laugh`, `confused`, `heart`, `hooray`, `rocket`, `eyes`) | |
68
+
| `reactions-edit-mode` | The mode when updating comment reactions, `replace` or `append`. | `append` |
69
+
70
+
Note: In *public* repositories this action does not work in `pull_request` workflows when triggered by forks.
71
+
Any attempt will be met with the error, `Resource not accessible by integration`.
72
+
This is due to token restrictions put in place by GitHub Actions. Private repositories can be configured to [enable workflows](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#enabling-workflows-for-forks-of-private-repositories) from forks to run without restriction. See [here](https://github.com/peter-evans/create-pull-request/blob/main/docs/concepts-guidelines.md#restrictions-on-repository-forks) for further explanation. Alternatively, use the [`pull_request_target`](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target) event to comment on pull request commits.
33
73
34
-
## Example
74
+
#### Outputs
35
75
36
-
Here is an example setting optional input parameters.
76
+
The ID of the created comment will be output for use in later steps.
77
+
Note that in order to read the step output the action step must have an id.
echo "Comment ID - ${{ steps.cc.outputs.comment-id }}"
51
89
```
52
90
53
91
### Setting the comment body from a file
54
92
55
-
This example shows how file content can be read into a variable and passed to the action.
93
+
```yml
94
+
- name: Create commit comment
95
+
uses: peter-evans/commit-comment@v3
96
+
with:
97
+
body-path: 'comment-body.md'
98
+
```
99
+
100
+
### Using a markdown template
56
101
102
+
In this example, a markdown template file is added to the repository at `.github/comment-template.md` with the following content.
103
+
```
104
+
This is a test comment template
105
+
Render template variables such as {{ .foo }} and {{ .bar }}.
106
+
```
107
+
108
+
The template is rendered using the [render-template](https://github.com/chuhlomin/render-template) action and the result is used to create the comment.
### Accessing commits and comments in other repositories
73
126
74
-
You can create a commit comment in another repository by using a [PAT](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token) instead of `GITHUB_TOKEN`.
127
+
You can create and update commit comments in another repository by using a [PAT](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) instead of `GITHUB_TOKEN`.
75
128
The user associated with the PAT must have write access to the repository.
0 commit comments