From 0b2fb2a01e33ddc098e8e21e5314d00c11ad3486 Mon Sep 17 00:00:00 2001 From: Shakar Bakr <5h4k4r.b4kr@gmail.com> Date: Tue, 19 Sep 2023 13:56:59 +0300 Subject: [PATCH] Append newline to the end of the file Signed-off-by: Shakar Bakr <5h4k4r.b4kr@gmail.com> --- index.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 240d75e..a6b62cb 100644 --- a/index.js +++ b/index.js @@ -61,9 +61,12 @@ async function run() { // Region functions async function commitChanges(file, filePath) { const commitMessage = 'Commit message here'; - const newContent = file; - const githubToken = core.getInput('githubToken'); + let newContent = JSON.stringify(newContent, null, 2); + // Append a newline character to the end of the new content + newContent += '\n'; + + const githubToken = core.getInput('githubToken'); // Get the repository owner and name const repoFullName = process.env.GITHUB_REPOSITORY; @@ -84,7 +87,7 @@ async function commitChanges(file, filePath) { const blobResponse = await axios.post( `https://api.github.com/repos/${owner}/${repo}/git/blobs`, { - content: JSON.stringify(newContent, null, 2), + content: newContent, encoding: 'utf-8', }, {