Skip to content

Commit 889bf6f

Browse files
committed
Set sha only when defined
1 parent 48426cd commit 889bf6f

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

action/dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

action/index.mjs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
console.log(`Committer REST API | ok`)
9292
console.log(`Committer | ${(await rest.users.getAuthenticated()).data.login}`)
9393
//Retrieve previous render SHA to be able to update file content through API
94-
let sha = undefined
94+
let sha = null
9595
try {
9696
const {data} = await rest.repos.getContent({
9797
owner:user,
@@ -103,8 +103,9 @@
103103
console.log(`Previous render sha | ${sha || "none"}`)
104104
//Update file content through API
105105
await rest.repos.createOrUpdateFileContents({
106-
owner:user, repo:user, path:filename, sha, message:`Update ${filename} - [Skip GitHub Action]`,
106+
owner:user, repo:user, path:filename, message:`Update ${filename} - [Skip GitHub Action]`,
107107
content:Buffer.from(rendered).toString("base64"),
108+
...(sha ? {sha} : {})
108109
})
109110
console.log(`Commit to repo | ok`)
110111
}

0 commit comments

Comments
 (0)