diff --git a/src/comments.js b/src/comments.js index 6dffe84..bd7e168 100644 --- a/src/comments.js +++ b/src/comments.js @@ -34,7 +34,8 @@ class Comments { /* add helper for checking change in commit */ Handlebars.registerHelper('commitChanged', commitHelper) /* setup templating for comments */ - this.template = Handlebars.compile(template); + Handlebars.registerPartial('build', template.build) + this.template = Handlebars.compile(template.main); } async renderComment (pr) { diff --git a/src/template.js b/src/template.js index 26f826d..ba3895e 100644 --- a/src/template.js +++ b/src/template.js @@ -1,4 +1,4 @@ -module.exports = ` +const main = ` ### Jenkins Builds | :grey_question: | Commit | :hash: | Finished (UTC) | Duration | Platform | Result | |-|-|-|-|-|-|-| @@ -6,10 +6,14 @@ module.exports = ` {{#commitChanged ../builds @index}} | | | | | | | | {{/commitChanged}} +{{> build }} +{{/each}} +` +const build = ` {{#if this.success}} | :heavy_check_mark: | {{ this.commit }} | [{{ this.id }}]({{ this.url }}) | {{date this.meta.created }} | {{ this.duration }} | \`{{ this.platform }}\` | [:package: package]({{ this.pkg_url }}) | {{else}} | :x: | {{ this.commit }} | [{{ this.id }}]({{ this.url }}) | {{date this.meta.created }} | {{ this.duration }} | \`{{ this.platform }}\` | [:page_facing_up: build log]({{ this.url }}consoleText) | {{/if}} -{{/each}} -` +`.trim() +module.exports = { main, build }