(payload: SyncPayload)
| 17 | } |
| 18 | |
| 19 | export const githubCreateFile = async (payload: SyncPayload): Promise<CreateOrUpdateResponse> => { |
| 20 | const octokit = new Octokit({ |
| 21 | auth: payload.userConfig?.accessToken, |
| 22 | }) |
| 23 | |
| 24 | const fileName = payload.title |
| 25 | const filePath = `${payload.userConfig.pathPrefix || ''}/${fileName}`.replace(/^\//, '') |
| 26 | |
| 27 | // Base64 encode the file content |
| 28 | const encodedContent = base64encode(payload.markdown) |
| 29 | |
| 30 | const res = await octokit.request('PUT /repos/{owner}/{repo}/contents/{path}', { |
| 31 | owner: payload.userConfig.owner, |
| 32 | repo: payload.userConfig.repo, |
| 33 | path: filePath, |
| 34 | message: `add ${fileName}`, |
| 35 | content: encodedContent, |
| 36 | sha: payload.sha, |
| 37 | }) |
| 38 | |
| 39 | return res as CreateOrUpdateResponse |
| 40 | } |
| 41 | |
| 42 | export const githubUpdateFile = async (payload: SyncPayload) => { |
| 43 | const octokit = new Octokit({ |
no test coverage detected