-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from liuderchi/poc/custom-template
Custom Templates
- Loading branch information
Showing
17 changed files
with
342 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
const { handleIssueWH, handlePullRequestWH } = require('./webhookHandler') | ||
const { handleIssueWH, handleIssueCommentWH, handlePullRequestWH } = require('./webhookHandler') | ||
|
||
module.exports = robot => { | ||
robot.on(['issues.opened', 'issues.edited'], handleIssueWH) | ||
robot.on(['issue_comment.created', 'issue_comment.edited'], handleIssueCommentWH) | ||
robot.on(['pull_request.opened', 'pull_request.edited'], handlePullRequestWH) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<!-- this is result of command `/template`--> | ||
|
||
## 🤖 Hello {{ withDefault username "Human" }}! I Understand These Commands: | ||
|
||
### `/template issue` | ||
|
||
open `.github/ISSUE_TEMPLATE.md` or a *[sample issue][issue]* | ||
|
||
### `/template pr` | ||
|
||
open `.github/PULL_REQUEST_TEMPLATE.md` or a *[sample pull request][pr]* | ||
|
||
### `/template feature` | ||
|
||
open *[a template to propose new feature][feature]* | ||
|
||
### `/template duplicate --num 23` | ||
|
||
open custom [Handlebars Template][handlebarsjs], in this case `.github/duplicate.md` with `num` set to 23 | ||
|
||
for example, you've had `.github/duplicate.md` like [this][example]: | ||
|
||
```markdown | ||
<!-- .github/duplicate.md --> | ||
😢 This is duplicate of #{{ withDefault __ "{{ num }}" }}. | ||
``` | ||
|
||
I would say `😢 This is duplicate of #23.` | ||
|
||
--- | ||
|
||
> Remember to :recycle:**Refresh This Page** after updating your command. | ||
[issue]: https://github.com/TalAter/open-source-templates | ||
[pr]: https://raw.githubusercontent.com/stevemao/github-issue-templates/master/simple/PULL_REQUEST_TEMPLATE.md | ||
[feature]: https://github.com/TalAter/open-source-templates | ||
[handlebarsjs]: http://handlebarsjs.com/ | ||
[example]: https://github.com/liuderchi/gh-template-bot/blob/master/src/templates/duplicate.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<!-- sample command: /template duplicate --num 23 --> | ||
|
||
😢 This is duplicate of #{{ num }}. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<!-- https://www.talater.com/open-source-templates/#/page/99 --> | ||
<!-- https://raw.githubusercontent.com/stevemao/github-issue-templates/master/simple/PULL_REQUEST_TEMPLATE.md --> | ||
|
||
Fixes #{{ n }} | ||
|
||
## Proposed Changes | ||
|
||
- | ||
- | ||
- |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
const R = require('ramda') | ||
|
||
|
||
const getCustomTemplates = async (gitHubContext, { owner, repo, path='.github' }) => { | ||
const { repos: { getContent } } = gitHubContext | ||
try { | ||
const { data: customTemplates } = await getContent({ owner, repo, path }) | ||
return customTemplates | ||
.filter(({ name, type }) => R.match(/\.md$/, name).length > 0 && type === 'file') | ||
.map(R.pick(['name', 'download_url'])) | ||
} catch (e) { | ||
console.error(e) | ||
return [] | ||
} | ||
} | ||
|
||
|
||
module.exports = { | ||
getCustomTemplates, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
const Handlebars = require('handlebars') | ||
|
||
Handlebars.registerHelper('withDefault', (x, defaultValue) => x ? x : defaultValue) | ||
|
||
module.exports = { | ||
Handlebars, | ||
} |
Oops, something went wrong.