| 5 | type CreateOrUpdateResponse = Endpoints[`PUT /repos/{owner}/{repo}/contents/{path}`]['response'] |
| 6 | |
| 7 | function base64encode(str: string) { |
| 8 | if (typeof btoa === 'function') { |
| 9 | return btoa( |
| 10 | encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function toSolidBytes(match, p1) { |
| 11 | return String.fromCharCode(Number(`0x${p1}`)) |
| 12 | }), |
| 13 | ) |
| 14 | } |
| 15 | if (typeof Buffer !== 'undefined') return Buffer.from(str, 'utf8').toString('base64') |
| 16 | throw new Error('Can not find window.btoa or Buffer') |
| 17 | } |
| 18 | |
| 19 | export const githubCreateFile = async (payload: SyncPayload): Promise<CreateOrUpdateResponse> => { |
| 20 | const octokit = new Octokit({ |