(payload: SyncPayload)
| 40 | } |
| 41 | |
| 42 | export const githubUpdateFile = async (payload: SyncPayload) => { |
| 43 | const octokit = new Octokit({ |
| 44 | auth: payload.userConfig?.accessToken, |
| 45 | }) |
| 46 | |
| 47 | const fileName = payload.title |
| 48 | const filePath = `${payload.userConfig.pathPrefix}/${fileName}` |
| 49 | |
| 50 | const currentFileInfo = await octokit.request('GET /repos/{owner}/{repo}/contents/{path}', { |
| 51 | owner: payload.userConfig.owner, |
| 52 | repo: payload.userConfig.repo, |
| 53 | path: filePath, |
| 54 | }) |
| 55 | |
| 56 | const { sha } = (currentFileInfo as { data: { sha: string } }).data |
| 57 | |
| 58 | const res = await githubCreateFile({ |
| 59 | ...payload, |
| 60 | sha, |
| 61 | }) |
| 62 | |
| 63 | return res |
| 64 | } |
no test coverage detected