diff --git a/__tests__/comment-upserter.test.ts b/__tests__/comment-upserter.test.ts
index ceaaa6a..1673397 100644
--- a/__tests__/comment-upserter.test.ts
+++ b/__tests__/comment-upserter.test.ts
@@ -38,8 +38,8 @@ describe('CommentUpserterImpl', () => {
const commentBody =
HEADER +
[
- '| db/migrate/** | @cto, @dba |',
- '| .github/**
spec/*.rb | @ci |'
+ '| db/migrate/\\*\\* | @cto, @dba |',
+ '| .github/\\*\\*
spec/\\*.rb | @ci |'
].join('\n')
const stubListComments = (comments: string[]): void => {
diff --git a/package-lock.json b/package-lock.json
index 7b11f11..51a606a 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -10,12 +10,14 @@
"@actions/core": "^1.10.0",
"@actions/github": "^5.1.0",
"js-yaml": "^4.1.0",
+ "markdown-escape": "^2.0.0",
"micromatch": "^4.0.4",
"parse-diff": "^0.11.1"
},
"devDependencies": {
"@octokit/webhooks-types": "^7.0.2",
"@types/js-yaml": "^4.0.5",
+ "@types/markdown-escape": "^1.1.3",
"@types/micromatch": "^4.0.2",
"@types/node": "^18.16.3",
"@typescript-eslint/parser": "^5.59.7",
@@ -1559,6 +1561,12 @@
"integrity": "sha1-7ihweulOEdK4J7y+UnC86n8+ce4=",
"dev": true
},
+ "node_modules/@types/markdown-escape": {
+ "version": "1.1.3",
+ "resolved": "https://registry.npmjs.org/@types/markdown-escape/-/markdown-escape-1.1.3.tgz",
+ "integrity": "sha512-JIc1+s3y5ujKnt/+N+wq6s/QdL2qZ11fP79MijrVXsAAnzSxCbT2j/3prHRouJdZ2yFLN3vkP0HytfnoCczjOw==",
+ "dev": true
+ },
"node_modules/@types/micromatch": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/@types/micromatch/-/micromatch-4.0.2.tgz",
@@ -5432,6 +5440,11 @@
"tmpl": "1.0.5"
}
},
+ "node_modules/markdown-escape": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/markdown-escape/-/markdown-escape-2.0.0.tgz",
+ "integrity": "sha512-Trz4v0+XWlwy68LJIyw3bLbsJiC8XAbRCKF9DbEtZjyndKOGVx6n+wNB0VfoRmY2LKboQLeniap3xrb6LGSJ8A=="
+ },
"node_modules/merge-stream": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz",
@@ -8091,6 +8104,12 @@
"integrity": "sha1-7ihweulOEdK4J7y+UnC86n8+ce4=",
"dev": true
},
+ "@types/markdown-escape": {
+ "version": "1.1.3",
+ "resolved": "https://registry.npmjs.org/@types/markdown-escape/-/markdown-escape-1.1.3.tgz",
+ "integrity": "sha512-JIc1+s3y5ujKnt/+N+wq6s/QdL2qZ11fP79MijrVXsAAnzSxCbT2j/3prHRouJdZ2yFLN3vkP0HytfnoCczjOw==",
+ "dev": true
+ },
"@types/micromatch": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/@types/micromatch/-/micromatch-4.0.2.tgz",
@@ -10897,6 +10916,11 @@
"tmpl": "1.0.5"
}
},
+ "markdown-escape": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/markdown-escape/-/markdown-escape-2.0.0.tgz",
+ "integrity": "sha512-Trz4v0+XWlwy68LJIyw3bLbsJiC8XAbRCKF9DbEtZjyndKOGVx6n+wNB0VfoRmY2LKboQLeniap3xrb6LGSJ8A=="
+ },
"merge-stream": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz",
diff --git a/package.json b/package.json
index f94b189..93bdedb 100644
--- a/package.json
+++ b/package.json
@@ -24,12 +24,14 @@
"@actions/core": "^1.10.0",
"@actions/github": "^5.1.0",
"js-yaml": "^4.1.0",
+ "markdown-escape": "^2.0.0",
"micromatch": "^4.0.4",
"parse-diff": "^0.11.1"
},
"devDependencies": {
"@octokit/webhooks-types": "^7.0.2",
"@types/js-yaml": "^4.0.5",
+ "@types/markdown-escape": "^1.1.3",
"@types/micromatch": "^4.0.2",
"@types/node": "^18.16.3",
"@typescript-eslint/parser": "^5.59.7",
diff --git a/src/comment-upserter.ts b/src/comment-upserter.ts
index 9c7a33e..37c7ec8 100644
--- a/src/comment-upserter.ts
+++ b/src/comment-upserter.ts
@@ -1,5 +1,6 @@
import * as core from '@actions/core'
import {RestEndpointMethods} from '@octokit/plugin-rest-endpoint-methods/dist-types/generated/method-types.d'
+import markdownEscape from 'markdown-escape'
import {MentionRule} from './configuration'
import {Repo} from './github-types'
@@ -80,7 +81,9 @@ export class CommentUpserterImpl implements CommentUpserter {
private createCommentBody(rules: MentionRule[]): string {
const body = rules
.map(rule => {
- const patterns = rule.patterns.join('
')
+ const patterns = rule.patterns
+ .map(pattern => markdownEscape(pattern, ['slashes']))
+ .join('
')
const mentions = rule.mentions.map(name => `@${name}`).join(', ')
return `| ${patterns} | ${mentions} |`
})