Skip to content

Commit

Permalink
fix: Cannot read property header or footer (#328)
Browse files Browse the repository at this point in the history
Fixes for #327

* build: add pre-release and remove-pre-release
  • Loading branch information
peaceiris authored Nov 25, 2020
1 parent 83a5f44 commit 1106b2a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
11 changes: 11 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,14 @@ test:
.PHONY: all
all:
docker-compose run --rm -T dev npm run all

.PHONY: pre-release
pre-release:
npm run build
git add ./lib/index.js
git commit -m "chore: npm run build"

.PHONY: remove-pre-release
remove-pre-release:
git rm -f ./lib/index.js
git commit -m "chore: remove lib/index.js"
12 changes: 8 additions & 4 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,21 +118,25 @@ export async function run(): Promise<void> {
const logURL = `${process.env['GITHUB_SERVER_URL']}/${process.env['GITHUB_REPOSITORY']}/actions/runs/${process.env['GITHUB_RUN_ID']}`;

// Merge comment body
const commentMain = config.labels[labelIndex][`${labelEvent}`][`${eventType}`].body + '\n\n';
const commentHeader = config.comment.header + '\n\n';
const commentFooter = config.comment.footer + '\n\n';
const commentMain = config.labels[labelIndex][`${labelEvent}`][`${eventType}`].body;
const commentHeader = config.comment?.header ?? '';
const commentFooter = config.comment?.footer ?? '';
const commentFooterLinks =
`<div align="right">` +
`<a href="${logURL}">Log</a>` +
` | ` +
`<a href="https://github.com/peaceiris/actions-label-commenter#readme">Bot Usage</a>` +
`</div>\n` +
'\n<!-- peaceiris/actions-label-commenter -->\n';
const rawCommentBody = commentHeader + commentMain + commentFooter + commentFooterLinks;
const rawCommentBody = `${commentHeader}\n\n${commentMain}\n\n${commentFooter}\n\n${commentFooterLinks}`;

if (commentMain === '' || commentMain === void 0) {
core.info(`[INFO] no configuration ${parentFieldName}.body`);
} else {
groupConsoleLog('commentMain', commentMain, core.isDebug());
groupConsoleLog('commentHeader', commentHeader, core.isDebug());
groupConsoleLog('commentFooter', commentFooter, core.isDebug());
groupConsoleLog('commentFooterLinks', commentFooterLinks, core.isDebug());
groupConsoleLog('rawCommentBody', rawCommentBody, core.isDebug());
}

Expand Down

0 comments on commit 1106b2a

Please sign in to comment.