{"id":20082253,"url":"https://github.com/exercism/pr-commenter-action","last_synced_at":"2025-05-06T00:31:45.985Z","repository":{"id":39863271,"uuid":"356854530","full_name":"exercism/pr-commenter-action","owner":"exercism","description":"The PR Commenter GitHub action posts comments on a PR that can vary depending on which files are being changed in the PR.","archived":false,"fork":false,"pushed_at":"2024-11-01T10:46:29.000Z","size":289,"stargazers_count":39,"open_issues_count":5,"forks_count":16,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-29T06:32:07.425Z","etag":null,"topics":["community-contributions-accepted"],"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/exercism.png","metadata":{"funding":{"github":["exercism"],"custom":["https://exercism.org/donate"]},"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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,"zenodo":null}},"created_at":"2021-04-11T11:55:19.000Z","updated_at":"2025-01-09T20:44:08.000Z","dependencies_parsed_at":"2023-02-06T06:46:52.115Z","dependency_job_id":"52ca42c2-c4c6-429c-9c0d-64ce50cbb3fe","html_url":"https://github.com/exercism/pr-commenter-action","commit_stats":{"total_commits":100,"total_committers":10,"mean_commits":10.0,"dds":"0.31999999999999995","last_synced_commit":"7d7179a693565f49de898d01cfd23fd2decab440"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exercism%2Fpr-commenter-action","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exercism%2Fpr-commenter-action/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exercism%2Fpr-commenter-action/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exercism%2Fpr-commenter-action/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/exercism","download_url":"https://codeload.github.com/exercism/pr-commenter-action/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252598416,"owners_count":21774253,"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":["community-contributions-accepted"],"created_at":"2024-11-13T15:42:33.014Z","updated_at":"2025-05-06T00:31:45.597Z","avatar_url":"https://github.com/exercism.png","language":"JavaScript","funding_links":["https://github.com/sponsors/exercism","https://exercism.org/donate"],"categories":[],"sub_categories":[],"readme":"# PR Commenter Action\n\nThis GitHub action posts comments on a PR that can vary depending on which files are being changed in the PR.\n \n## Getting Started\n\n### Create workflow\n\nCreate your workflow file `.github/workflows/pr-commenter.yml` as follows.\n\n```yaml\nname: \"PR Commenter\"\non:\n  - pull_request_target\n\njobs:\n  pr-comment:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: exercism/pr-commenter-action@v1.5.1\n        with:\n          github-token: \"${{ github.token }}\"\n          config-file: \".github/pr-commenter.yml\"\n```\n\n### Create configuration file\n\nCreate your action configuration file `.github/pr-commenter.yml` as follows.\n\n```yaml\ncomment:\n  on-update: recreate\n  header: |\n    Thank you for contributing to this repository :tada:.\n\n  footer: |\n    ---\n    Automated comment created by [PR Commenter](https://github.com/exercism/pr-commenter-action) :robot:.\n\n  snippets:\n    - id: any-markdown-file-changed\n      files:\n        - '*.md'\n        - '**/*.md'\n      body: |\n        It looks like you're changing a Markdown file.\n        Make sure your changes follow our [language guidelines](some-link) when writing documentation.\n```\n\n## Reference\n\n### Workflow inputs\n\n#### `github-token`\n\nAuth token used to manage issues or pull requests.\n\n**Required**: true\n\n**Default**: `${{ github.token }}`\n\n#### `config-file`\n\n**Required**: true\n\n**Default**: `.github/pr-commenter.yml`\n\nTo reference a config file in another repo use the format: `\u003cowner\u003e/\u003crepo\u003e@\u003cref\u003e:\u003cpath\u003e`, for example `someuser/my-repo@v1:.github/pr-commenter.yml`. NOTE: make sure that \"my-repo\" is public and has \"Workflow permissions\" allowing files to be read.\n\n### Configuration file\n\n#### `comment.on-create`\n\nDictates what should happen if there is no comment on this PR yet. For almost all use cases, you want to keep the default behavior. The custom `nothing` option makes sense if you're using this action twice on the same PR, and you want the second execution not to create a new comment, but only edit it if it already exists from the first execution.\n\n- `create` - create a new comment\n- `nothing` - do not create a new comment\n\nAlso accepts a Mustache template that evaluates to one of the above values.\n\n**Required**: false\n\n**Default**: `create`\n\n#### `comment.on-update`\n\nDictates what should happen if a comment was already created on this PR, but more changes were pushed to the PR and the comment needs to change.\n\n- `recreate` - delete the old comment and create a new one\n- `edit` - edit the old comment\n- `nothing` - leave the old comment unchanged\n\nAlso accepts a Mustache template that evaluates to one of the above values.\n\n**Required**: true\n\n**Default**: `recreate`\n\n#### `comment.header`\n\nAn optional text to be included at the beginning of each comment. \n\n**Required**: false\n\n#### `comment.footer`\n\nAn optional text to be included at the end of each comment. \n\n**Required**: false\n\n#### `comment.snippets`\n\nA list of comment snippet configurations. At least one snippet is required. Note that a PR comment will only be created if at least one of the snippets match, even if `comment.header` and/or `comment.footer` are given.\n\n**Required**: true\n\n#### `comment.snippets[].id`\n\nA string consisting of letters, numbers, `-`, and `_` or a Mustache template that evaluates to such a string.\n\n_Snippet ids are used to check whether a comment's content changed. If you're using a template variable in the snippets's body and you want to recreate the whole comment when that variable changes value, use it in the snippet's id too._ \n\n**Required**: true\n\n#### `comment.snippets[].body`\n\nThe text to be included in the PR comment.\n\n**Required**: true\n\n##### Templates\n\nComment snippet bodies and ids (as well as `comment.on-create`, `comment.on-update`, `comment.header`, and `comment.footer`) are [Mustache](https://mustache.github.io/mustache.5.html) templates.\n\nVariables for the template can be provided via the `template-variables` input which should be a string containing a valid JSON.\n\nYou can use the [context and expression syntax](https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions) to assemble the JSON and [set-output](https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-output-parameter) to calculate data for the template in separate steps.\n\n###### Example 1\n\n```yaml\nname: \"PR Commenter\"\non:\n  - pull_request_target\n\njobs:\n  pr-comment:\n    runs-on: ubuntu-latest\n    steps:\n      - name: Calculate some template variables\n        id: vars\n        run: |\n          echo ::set-output name=today::\"$(date +%d-%m-%Y)\"\n\n      - uses: exercism/pr-commenter-action@v1.5.0\n        with:\n          template-variables: |\n            {\n              \"today\": \"${{ steps.vars.outputs.today }}\",\n              \"prAuthor\": \"${{ github.event.pull_request.user.login }}\",\n              \"branchNamePrefix\": ${{ startsWith(github.event.pull_request.head.ref, 'ref-') }}\n            }\n```\n```yaml\ncomment:\n  header: |\n    Hi {{ prAuthor }}! Thank you for your contribution.\n\n    {{^branchNamePrefix}}Your branch name doesn't start with the required prefix 'ref-'.{{/branchNamePrefix}}\n```\n\nNote that values such as the PR's title, body, or branch name should be considered [unsafe user input](https://docs.github.com/en/actions/learn-github-actions/security-hardening-for-github-actions#understanding-the-risk-of-script-injections).\n\n###### Example 2\n\nHere's a more complex example of using template variables. Let's say you have a multiline file that changes often, and you want to always include the newest content of the file in the snippet.\n\nTo ensure the comment will be recreated when the file changes, use the file's hash in the snippet's id.\n\nTo ensure that newline characters are handled correctly, use environment variables instead of job outputs and `toJSON`.\n\n```yaml\nname: \"PR Commenter\"\non:\n  - pull_request_target\n\njobs:\n  pr-comment:\n    runs-on: ubuntu-latest\n    steps:\n      - name: Set environment variables\n        run: |\n          IMPORTANT_FILE_CONTENT=$(cat important_file)\n          echo \"IMPORTANT_FILE_CONTENT\u003c\u003cEOF\" \u003e\u003e $GITHUB_ENV\n          echo \"$IMPORTANT_FILE_CONTENT\" \u003e\u003e $GITHUB_ENV\n          echo \"EOF\" \u003e\u003e $GITHUB_ENV\n\n      - uses: exercism/pr-commenter-action@v1.5.0\n        with:\n          template-variables: |\n            {\n              \"importantFileContent\": ${{ toJSON(env.IMPORTANT_FILE_CONTENT) }},\n              \"importnatFileHash\": ${{ toJSON(hashFiles('important_file.txt')) }}\n            }\n```\n```yaml\ncomment:\n  snippets:\n    - id: snippet_{{ importnatFileHash }}}\n    - files:\n      - 'important_file.txt'\n    - body: |\n        This is very important:\n        {{ importantFileContent }}\n```\n\n#### `comment.snippets[].files`\n\nA list of globs (strings) and/or match objects. If at least one file changed in the PR matches at least one of the globs or match objects, this snippet's body will be included in the comment.\n\n##### Globs\n\nExample:\n\n```yaml\n# any markdown file changed in any directory\ncomment:\n  snippets:\n    - id: any-markdown-file-changed\n      files:\n        - '*.md'\n        - '**/*.md'\n```\n\n##### Match objects\n\nA match object contains the keys `any` and/or `all` with a list of globs.\n\n- `all` - **every file** changed in this PR must match every glob in this list\n- `any` - **at least one file** changed in this PR must match every glob in this list\n\nExample:\n\n```yaml\n# at least one root-level markdown file changed\n# and none of the changed files is the README.md\ncomment:\n  snippets:\n    - id: any-markdown-file-changed-but-readme\n      files:\n        - any: ['*.md']\n          all: ['!README.md']\n```\n\n**Required**: true\n\n#### `comment.glob-options`\n\nThis GitHub action uses the [minimatch](https://github.com/isaacs/minimatch) library for glob matching. A object with options can be provided under `comment.glob-options` to modify the behavior of this library. See [the list of minimatch options](https://github.com/isaacs/minimatch#options) for the list of supported options.\n\nExample:\n\n```yaml\n# Make all globs also match hidden files and directories\ncomment:\n  glob-options:\n    dot: true\n```\n\n## Development\n\n### Setup\n\n- Install the required NodeJS version as specified in `.tool-versions`. The recommended way to manage multiple NodeJS versions is to use [asdf](https://asdf-vm.com/#/).\n- Install the dependencies with `npm install`.\n- Run the tests with `npm run test` and the linter with `npm run lint`.\n\n## Authors\n\nThis library was originally created by [@angelikatyborska](https://github.com/angelikatyborska/). It is maintained by [@angelikatyborska](https://github.com/angelikatyborska/) and the Exercism team. See the [GitHub contributors graph](https://github.com/exercism/pr-commenter-action/graphs/contributors) for a full list of contributors.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexercism%2Fpr-commenter-action","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fexercism%2Fpr-commenter-action","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexercism%2Fpr-commenter-action/lists"}