@@ -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
2726async 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