| 33 | |
| 34 | // Setup git remote |
| 35 | export const gitRemoteAdd = async (name: string): Promise<void> => { |
| 36 | const remoteURL = await execa('git', [ |
| 37 | 'config', |
| 38 | '--get', |
| 39 | 'remote.origin.url', |
| 40 | ]); |
| 41 | // Strip https:// from remote link get |
| 42 | const strippedURL = new URL(remoteURL.stdout).host; |
| 43 | |
| 44 | // git remote add origin https://username:access-token@github.com/username/repo.git |
| 45 | const publishURL = `https://${name}:${ |
| 46 | // biome-ignore lint/style/noNonNullAssertion: It is guaranteed to be there. |
| 47 | process.env.GITHUB_TOKEN! |
| 48 | }@${strippedURL}`; |
| 49 | try { |
| 50 | await execa('git', ['remote', 'add', 'origin', publishURL]); |
| 51 | } catch { |
| 52 | // Git origin already exists. Continue |
| 53 | } |
| 54 | }; |
| 55 | |
| 56 | export const gitPush = async (): Promise<void> => { |
| 57 | await execa('git', ['push', 'origin', 'main']); |