Skip to content

Commit

Permalink
refactor: ♻️ use mustache to render comment
Browse files Browse the repository at this point in the history
  • Loading branch information
bubkoo committed Oct 9, 2020
1 parent bb1638d commit 2d7f0cd
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 19 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ jobs:
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
FIRST_ISSUE: >
Hi 👋 @${author}
Hi 👋 @{{ author }}
Thanks for opening your first issue here! Be sure to follow the issue template!
FIRST_PR: >
👋 @${author}
👋 @{{ author }}
Thanks for opening this pull request! Please check out our contributing guidelines.
FIRST_PR_MERGED: >
🎉 @${author}
🎉 @{{ author }}
Congrats on merging your first pull request! We here at behaviorbot are proud of you!
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ jobs:
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
FIRST_ISSUE: >
👋 @${author}
👋 @{{ author }}
Thanks for opening your first issue here! Be sure to follow the issue template!
FIRST_PR: >
👋 @${author}
👋 @{{ author }}
Thanks for opening this pull request! Please check out our contributing guidelines.
FIRST_PR_MERGED: >
🎉 @${author}
🎉 @{{ author }}
Congrats on merging your first pull request! We here at behaviorbot are proud of you!
```
Expand All @@ -47,6 +47,7 @@ jobs:
- `FIRST_PR_MERGED_REACTIONS`: Reactions to be add to comment on pull requests merged by a first time user.

Available reactions:

- `+1` 👍
- `-1` 👎
- `laugh` 😄
Expand Down Expand Up @@ -74,7 +75,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
FIRST_ISSUE_REACTIONS: '+1, hooray, rocket, heart'
FIRST_ISSUE_COMMENT: >
👋 @${author}
👋 @{{ author }}
Thanks for opening your first issue here! Be sure to follow the issue template!
```
Expand All @@ -95,7 +96,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
FIRST_PR_REACTIONS: '+1, hooray, rocket, heart'
FIRST_PR_COMMENT: >
👋 @${author}
👋 @{{ author }}
Thanks for opening this pull request! Please check out our contributing guidelines.
```
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "welcome-action",
"version": "1.0.1",
"version": "1.0.2",
"description": "GitHub action to give a welcome comment on first issue or PR 💖",
"main": "dist/index.js",
"files": [
Expand Down Expand Up @@ -40,13 +40,13 @@
"@actions/core": "^1.2.6",
"@actions/github": "^4.0.0",
"lodash.random": "^3.2.0",
"lodash.template": "^4.5.0"
"mustache": "^4.0.1"
},
"devDependencies": {
"@commitlint/cli": "^11.0.0",
"@commitlint/config-conventional": "^11.0.0",
"@types/lodash.random": "^3.2.6",
"@types/lodash.template": "^4.5.0",
"@types/mustache": "^4.0.1",
"@types/node": "^14.0.27",
"@typescript-eslint/eslint-plugin": "^4.1.1",
"@typescript-eslint/parser": "^4.1.1",
Expand Down
4 changes: 2 additions & 2 deletions src/util.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import mustache from 'mustache'
import random from 'lodash.random'
import template from 'lodash.template'
import * as core from '@actions/core'
import * as github from '@actions/github'

Expand All @@ -16,7 +16,7 @@ export namespace Util {
result = comment[pos] || comment[0]
}

return args ? template(result)(args) : result
return args ? mustache.render(result, args) : result
}

export function isValidEvent(event: string, action?: string) {
Expand Down
10 changes: 10 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,11 @@
resolved "https://registry.npmjs.org/@types/minimist/-/minimist-1.2.0.tgz#69a23a3ad29caf0097f06eda59b361ee2f0639f6"
integrity sha1-aaI6OtKcrwCX8G7aWbNh7i8GOfY=

"@types/mustache@^4.0.1":
version "4.0.1"
resolved "https://registry.npmjs.org/@types/mustache/-/mustache-4.0.1.tgz#e4d421ed2d06d463b120621774185a5cd1b92d77"
integrity sha512-wH6Tu9mbiOt0n5EvdoWy0VGQaJMHfLIxY/6wS0xLC7CV1taM6gESEzcYy0ZlWvxxiiljYvfDIvz4hHbUUDRlhw==

"@types/node@>= 8", "@types/node@^14.0.27":
version "14.11.2"
resolved "https://registry.npmjs.org/@types/node/-/node-14.11.2.tgz#2de1ed6670439387da1c9f549a2ade2b0a799256"
Expand Down Expand Up @@ -1795,6 +1800,11 @@ multimatch@^4.0.0:
arrify "^2.0.1"
minimatch "^3.0.4"

mustache@^4.0.1:
version "4.0.1"
resolved "https://registry.npmjs.org/mustache/-/mustache-4.0.1.tgz#d99beb031701ad433338e7ea65e0489416c854a2"
integrity sha512-yL5VE97+OXn4+Er3THSmTdCFCtx5hHWzrolvH+JObZnUYwuaG7XV+Ch4fR2cIrcYI0tFHxS7iyFYl14bW8y2sA==

natural-compare@^1.4.0:
version "1.4.0"
resolved "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7"
Expand Down

0 comments on commit 2d7f0cd

Please sign in to comment.