{"id":14985919,"url":"https://github.com/thollander/actions-comment-pull-request","last_synced_at":"2025-04-10T17:16:16.701Z","repository":{"id":35559157,"uuid":"218601347","full_name":"thollander/actions-comment-pull-request","owner":"thollander","description":"GitHub action to comment pull request","archived":false,"fork":false,"pushed_at":"2025-01-28T05:03:32.000Z","size":1030,"stargazers_count":355,"open_issues_count":22,"forks_count":97,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-03T04:02:36.722Z","etag":null,"topics":["actions","github","github-actions"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thollander.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-10-30T18:59:40.000Z","updated_at":"2025-03-28T09:17:32.000Z","dependencies_parsed_at":"2024-05-02T06:41:16.187Z","dependency_job_id":"d3a37c87-6e29-46c0-8be9-12615d40e05e","html_url":"https://github.com/thollander/actions-comment-pull-request","commit_stats":{"total_commits":177,"total_committers":9,"mean_commits":"19.666666666666668","dds":0.4689265536723164,"last_synced_commit":"e4a76dd2b0a3c2027c3fd84147a67c22ee4c90fa"},"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thollander%2Factions-comment-pull-request","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thollander%2Factions-comment-pull-request/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thollander%2Factions-comment-pull-request/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thollander%2Factions-comment-pull-request/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thollander","download_url":"https://codeload.github.com/thollander/actions-comment-pull-request/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248259850,"owners_count":21074207,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["actions","github","github-actions"],"created_at":"2024-09-24T14:11:57.044Z","updated_at":"2025-04-10T17:16:16.651Z","avatar_url":"https://github.com/thollander.png","language":"JavaScript","readme":"# Comment Pull Request - GitHub Actions\n\n## What is it ?\n\nA GitHub action that comments with a given message the pull request linked to the pushed branch.\nYou can even put dynamic data thanks to [Contexts and expression syntax](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/contexts-and-expression-syntax-for-github-actions).\n\n## Usage\n\n### Classic usage\n\n```yml\non: pull_request\n\njobs:\n  example_comment_pr:\n    runs-on: ubuntu-latest\n    name: An example job to comment a PR\n    steps:\n      - name: Checkout\n        uses: actions/checkout@v3\n\n      - name: Comment PR\n        uses: thollander/actions-comment-pull-request@v3\n        with:\n          message: |\n            Hello world ! :wave:\n```\n\n### Comment a file content\n\nThanks to the `file-path` input, a file content can be commented.\nYou can either pass an absolute file-path or a relative one that will be by default retrieved from `GITHUB_WORKSPACE`. \n(Note that if both a `message` and `file-path` are provided, `message` will take precedence.)\n\n```yml\n- name: PR comment with file\n  uses: thollander/actions-comment-pull-request@v3\n  with:\n    file-path: /path/to/file.txt\n```\n\n\n### Setting reactions\n\nYou can also set some reactions on your comments through the `reactions` input.\nIt takes only valid reactions and adds it to the comment you've just created. (See https://docs.github.com/en/rest/reactions#reaction-types)\n\n```yml\n- name: PR comment with reactions\n  uses: thollander/actions-comment-pull-request@v3\n  with:\n    message: |\n      Hello world ! :wave:\n    reactions: eyes, rocket\n```\n\n### Specifying which pull request to comment on\n\nYou can explicitly input which pull request should be commented on by passing the `pr-number` input.\nThat is particularly useful for manual workflow for instance (`workflow_run`).\n\n```yml\n...\n- name: Comment PR\n  uses: thollander/actions-comment-pull-request@v3\n  with:\n    message: |\n      Hello world ! :wave:\n    pr-number: 123 # This will comment on pull request #123\n```\n\n\n### Update a comment\n\nEditing an existing comment is also possible thanks to the `comment-tag` input.\n\nThanks to this parameter, it will be possible to identify your comment and then to upsert on it. \nIf the comment is not found at first, it will create a new comment.\n\n_That is particularly interesting while committing multiple times in a PR and that you just want to have the last execution report printed. It avoids flooding the PR._\n\n```yml\n...\n- name: Comment PR with execution number\n  uses: thollander/actions-comment-pull-request@v3\n  with:\n    message: |\n      _(execution **${{ github.run_id }}** / attempt **${{ github.run_attempt }}**)_\n    comment-tag: execution\n```\n\nNote: the input `mode` can be used to either `upsert` (by default) or `recreate` the comment (= delete and create)\n\n### Delete a comment\n\n\nDeleting a comment with a specific `comment-tag` is possible with the `mode: delete`. If a comment with the `comment-tag` exists, it will be deleted when ran.\n\n```yml\n...\n- name: Delete a comment\n  uses: thollander/actions-comment-pull-request@v3\n  with:\n    comment-tag: to_delete\n    mode: delete\n```\n\n### Delete a comment on job completion\n\nDeleting an existing comment on job completion is also possible thanks to the `comment-tag` input combined with `mode: delete-on-completion`.\n\nThis will delete the comment at the end of the job. \n\n```yml\n...\n- name: Write a comment that will be deleted at the end of the job\n  uses: thollander/actions-comment-pull-request@v3\n  with:\n    message: |\n      The PR is being built...\n    comment-tag: to_delete_on_completion\n    mode: delete-on-completion\n```\n\n## Inputs \n\n### Action inputs\n\n| Name | Description | Required | Default |\n| --- | --- | --- | --- |\n| `github-token` | Token that is used to create comments. Defaults to ${{ github.token }} | ✅ | |\n| `message` | Comment body | | |\n| `file-path` | Path of the file that should be commented | | |\n| `reactions` | List of reactions for the comment (comma separated). See https://docs.github.com/en/rest/reactions#reaction-types  | | |\n| `pr-number` | The number of the pull request where to create the comment | | current pull-request/issue number (deduced from context) |\n| `comment-tag` | A tag on your comment that will be used to identify a comment in case of replacement | | |\n| `mode` | Mode that will be used to update comment (upsert/recreate/delete/delete-on-completion) | | upsert |\n| `create-if-not-exists` | Whether a comment should be created even if `comment-tag` is not found | | true |\n\n\n## Outputs \n\n### Action outputs\n\nYou can get some outputs from this actions : \n\n| Name | Description |\n| --- | --- |\n| `id` | Comment id that was created or updated | \n| `body` | Comment body |\n| `html-url` | URL of the comment created or updated |\n\n### Example output\n\n```yaml\n- name: Comment PR\n  uses: thollander/actions-comment-pull-request@v3\n  id: hello\n  with:\n    message: |\n      Hello world ! :wave:\n- name: Check outputs\n  run: |\n    echo \"id : ${{ steps.hello.outputs.id }}\"\n    echo \"body : ${{ steps.hello.outputs.body }}\"\n    echo \"html-url : ${{ steps.hello.outputs.html-url }}\"\n```\n\n## Permissions\n\nDepending on the permissions granted to your token, you may lack some rights. \nTo run successfully, this actions needs at least : \n\n```yaml\npermissions: \n   pull-requests: write \n```\n\nAdd this in case you get `Resource not accessible by integration` error.\nSee [jobs.\u003cjob_id\u003e.permissions](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idpermissions) for more information.\n\n\n\u003e Note that, if the PR comes from a fork, it will have only read permission despite the permissions given in the action for the `pull_request` event.\n\u003e In this case, you may use the `pull_request_target` event. With this event, permissions can be given without issue (the difference is that it will execute the action from the target branch and not from the origin PR).\n\n## Contributing\n\n### Build\n\nThe build steps transpiles the `src/main.ts` to `lib/index.js` which is used in a NodeJS environment.\nIt is handled by `vercel/ncc` compiler.\n\n```sh\n$ npm run build\n```\n","funding_links":[],"categories":["Acknowledgments","JavaScript"],"sub_categories":["Github Actions"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthollander%2Factions-comment-pull-request","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthollander%2Factions-comment-pull-request","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthollander%2Factions-comment-pull-request/lists"}