Skip to content

Commit dd1651a

Browse files
committed
Send sha
1 parent ed1bcd2 commit dd1651a

2 files changed

Lines changed: 12 additions & 10 deletions

File tree

.github/actions/changelog/lib/index.js

Lines changed: 6 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/actions/changelog/src/index.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@ async function main() {
1818
github.context.payload &&
1919
github.context.payload.pull_request &&
2020
github.context.payload.pull_request.title
21-
core.info('title: ' + title)
22-
const changelog = await getChangelog()
21+
const { changelog, sha } = await getChangelog()
2322
const updatedChangelog = { draft: [title, ...changelog.draft], ...changelog }
24-
await commitChangelog(updatedChangelog)
23+
await commitChangelog(updatedChangelog, sha)
2524
}
2625

2726
async function getChangelog() {
@@ -31,11 +30,12 @@ async function getChangelog() {
3130
const path = 'changelog.json'
3231
const response = await octokit.repos.getContents({ owner, repo, path })
3332
const base64Content = (response.data as any).content
33+
const sha = (response.data as any).sha
3434
const content = Buffer.from(base64Content, 'base64').toString('utf8')
35-
return JSON.parse(content)
35+
return { changelog: JSON.parse(content), sha }
3636
}
3737

38-
async function commitChangelog(changelog: Changelog) {
38+
async function commitChangelog(changelog: Changelog, sha: string) {
3939
const octokit = new github.GitHub(GITHUB_TOKEN)
4040
const owner = github.context.repo.owner
4141
const repo = github.context.repo.repo
@@ -49,6 +49,7 @@ async function commitChangelog(changelog: Changelog) {
4949
path,
5050
message,
5151
content,
52+
sha,
5253
})
5354

5455
if (response.status != 200) {

0 commit comments

Comments
 (0)