Set sha only when defined
This commit is contained in:
2
action/dist/index.js
vendored
2
action/dist/index.js
vendored
File diff suppressed because one or more lines are too long
@@ -91,7 +91,7 @@
|
|||||||
console.log(`Committer REST API | ok`)
|
console.log(`Committer REST API | ok`)
|
||||||
console.log(`Committer | ${(await rest.users.getAuthenticated()).data.login}`)
|
console.log(`Committer | ${(await rest.users.getAuthenticated()).data.login}`)
|
||||||
//Retrieve previous render SHA to be able to update file content through API
|
//Retrieve previous render SHA to be able to update file content through API
|
||||||
let sha = undefined
|
let sha = null
|
||||||
try {
|
try {
|
||||||
const {data} = await rest.repos.getContent({
|
const {data} = await rest.repos.getContent({
|
||||||
owner:user,
|
owner:user,
|
||||||
@@ -103,8 +103,9 @@
|
|||||||
console.log(`Previous render sha | ${sha || "none"}`)
|
console.log(`Previous render sha | ${sha || "none"}`)
|
||||||
//Update file content through API
|
//Update file content through API
|
||||||
await rest.repos.createOrUpdateFileContents({
|
await rest.repos.createOrUpdateFileContents({
|
||||||
owner:user, repo:user, path:filename, sha, message:`Update ${filename} - [Skip GitHub Action]`,
|
owner:user, repo:user, path:filename, message:`Update ${filename} - [Skip GitHub Action]`,
|
||||||
content:Buffer.from(rendered).toString("base64"),
|
content:Buffer.from(rendered).toString("base64"),
|
||||||
|
...(sha ? {sha} : {})
|
||||||
})
|
})
|
||||||
console.log(`Commit to repo | ok`)
|
console.log(`Commit to repo | ok`)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user