pull/787/head
f 2 weeks ago
parent 8a35568fe7
commit 926b5964a2

@ -231,7 +231,24 @@ jobs:
sha: mainRef.object.sha sha: mainRef.object.sha
}); });
// Get current files from the new branch
console.log('Getting current file SHAs...');
const { data: currentReadme } = await octokit.repos.getContent({
owner: event.repository.owner.login,
repo: event.repository.name,
path: 'README.md',
ref: branchName
});
const { data: currentCsv } = await octokit.repos.getContent({
owner: event.repository.owner.login,
repo: event.repository.name,
path: 'prompts.csv',
ref: branchName
});
// Update files with correct author // Update files with correct author
console.log('Updating README.md...');
await octokit.repos.createOrUpdateFileContents({ await octokit.repos.createOrUpdateFileContents({
owner: event.repository.owner.login, owner: event.repository.owner.login,
repo: event.repository.name, repo: event.repository.name,
@ -239,6 +256,7 @@ jobs:
message: `feat: Add "${actName}" to README`, message: `feat: Add "${actName}" to README`,
content: Buffer.from(readmeContent).toString('base64'), content: Buffer.from(readmeContent).toString('base64'),
branch: branchName, branch: branchName,
sha: currentReadme.sha,
committer: { committer: {
name: pr.user.login, name: pr.user.login,
email: `${pr.user.login}@users.noreply.github.com` email: `${pr.user.login}@users.noreply.github.com`
@ -249,6 +267,7 @@ jobs:
} }
}); });
console.log('Updating prompts.csv...');
await octokit.repos.createOrUpdateFileContents({ await octokit.repos.createOrUpdateFileContents({
owner: event.repository.owner.login, owner: event.repository.owner.login,
repo: event.repository.name, repo: event.repository.name,
@ -256,6 +275,7 @@ jobs:
message: `feat: Add "${actName}" to prompts.csv`, message: `feat: Add "${actName}" to prompts.csv`,
content: Buffer.from(csvContent).toString('base64'), content: Buffer.from(csvContent).toString('base64'),
branch: branchName, branch: branchName,
sha: currentCsv.sha,
committer: { committer: {
name: pr.user.login, name: pr.user.login,
email: `${pr.user.login}@users.noreply.github.com` email: `${pr.user.login}@users.noreply.github.com`

Loading…
Cancel
Save