Append newline to the end of the file

Signed-off-by: Shakar Bakr <5h4k4r.b4kr@gmail.com>
This commit is contained in:
Shakar Bakr 2023-09-19 13:56:59 +03:00
parent 3829330c4e
commit 0b2fb2a01e
No known key found for this signature in database
GPG Key ID: DA55A26823AE3C28

View File

@ -61,9 +61,12 @@ async function run() {
// Region functions // Region functions
async function commitChanges(file, filePath) { async function commitChanges(file, filePath) {
const commitMessage = 'Commit message here'; 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 // Get the repository owner and name
const repoFullName = process.env.GITHUB_REPOSITORY; const repoFullName = process.env.GITHUB_REPOSITORY;
@ -84,7 +87,7 @@ async function commitChanges(file, filePath) {
const blobResponse = await axios.post( const blobResponse = await axios.post(
`https://api.github.com/repos/${owner}/${repo}/git/blobs`, `https://api.github.com/repos/${owner}/${repo}/git/blobs`,
{ {
content: JSON.stringify(newContent, null, 2), content: newContent,
encoding: 'utf-8', encoding: 'utf-8',
}, },
{ {