diff --git a/action.yml b/action.yml index cb9e3cc..735b8f1 100644 --- a/action.yml +++ b/action.yml @@ -23,7 +23,9 @@ inputs: dry_run: type: boolean default: "false" - + token_for_target_repo: + description: "A token with write access to the target repo" + required: true runs: using: "node20" diff --git a/dist/index.js b/dist/index.js index 96666ab..80e802c 100644 --- a/dist/index.js +++ b/dist/index.js @@ -25707,7 +25707,9 @@ async function run() { // `YES`, `1`, etc. or indeed if it can even be `required`), and I want to default to `dry_run` the first time I run // this to avoid accidentally triggering a ton of commits before I get a chance to observe output. const dry_run = !(dry_run_inp == 'false'); - await (0, main_1.main)({ domain: source_domain, owner: source_owner, name: source_name }, { domain: target_domain, owner: target_owner, name: target_name }, dry_run); + const token_for_target_repo = core.getInput('token_for_target_repo'); + // Obviously, don't log this! + await (0, main_1.main)({ domain: source_domain, owner: source_owner, name: source_name }, { domain: target_domain, owner: target_owner, name: target_name }, dry_run, token_for_target_repo); // Set output core.setOutput('example-output', 'some value'); } @@ -25738,11 +25740,14 @@ const date_fns_1 = __nccwpck_require__(4367); const WORKING_DIR = './working'; const SOURCE_DIR = WORKING_DIR + '/source'; const TARGET_DIR = WORKING_DIR + '/target'; -async function main(sourceRepo, targetRepo, dryRun) { +async function main(sourceRepo, targetRepo, dryRun, tokenForTargetRepo) { // It _shouldn't_ ever exist, but it if did, something weird is going on. if ((0, fs_1.existsSync)(WORKING_DIR) || (0, fs_1.existsSync)(SOURCE_DIR) || (0, fs_1.existsSync)(TARGET_DIR)) { throw new Error('Working directory already exists/populated'); } + if (tokenForTargetRepo == '') { + throw new Error('token_for_target_repo is required'); + } (0, fs_1.mkdirSync)(WORKING_DIR); (0, fs_1.mkdirSync)(SOURCE_DIR); (0, fs_1.mkdirSync)(TARGET_DIR); @@ -25840,8 +25845,7 @@ async function main(sourceRepo, targetRepo, dryRun) { // // But I'm gonna do a bunch more dry-run testing before I do that! if (!dryRun) { - // TODO - oh, maybe there'll be some authentication problems here? Blech... - (0, child_process_1.execSync)(`git push`, { + (0, child_process_1.execSync)(`git push https://unused-username:${tokenForTargetRepo}@${targetRepo.domain}/${targetRepo.owner}/${targetRepo.name}`, { cwd: TARGET_DIR }); // TODO - it'd be nice - before this `git push` is probably best - to add a `README.md` comment acknowledging diff --git a/node_modules/@vercel/ncc/dist/ncc/cli.js.cache b/node_modules/@vercel/ncc/dist/ncc/cli.js.cache index fc975b0..1b340be 100644 Binary files a/node_modules/@vercel/ncc/dist/ncc/cli.js.cache and b/node_modules/@vercel/ncc/dist/ncc/cli.js.cache differ diff --git a/node_modules/@vercel/ncc/dist/ncc/index.js.cache b/node_modules/@vercel/ncc/dist/ncc/index.js.cache index 71de8dc..b755d44 100644 Binary files a/node_modules/@vercel/ncc/dist/ncc/index.js.cache and b/node_modules/@vercel/ncc/dist/ncc/index.js.cache differ diff --git a/node_modules/@vercel/ncc/dist/ncc/loaders/relocate-loader.js.cache b/node_modules/@vercel/ncc/dist/ncc/loaders/relocate-loader.js.cache index 4549e2d..1a0a146 100644 Binary files a/node_modules/@vercel/ncc/dist/ncc/loaders/relocate-loader.js.cache and b/node_modules/@vercel/ncc/dist/ncc/loaders/relocate-loader.js.cache differ diff --git a/node_modules/@vercel/ncc/dist/ncc/loaders/shebang-loader.js.cache b/node_modules/@vercel/ncc/dist/ncc/loaders/shebang-loader.js.cache index 6b97df3..d74b8a3 100644 Binary files a/node_modules/@vercel/ncc/dist/ncc/loaders/shebang-loader.js.cache and b/node_modules/@vercel/ncc/dist/ncc/loaders/shebang-loader.js.cache differ diff --git a/node_modules/@vercel/ncc/dist/ncc/loaders/ts-loader.js.cache b/node_modules/@vercel/ncc/dist/ncc/loaders/ts-loader.js.cache index d06911b..b331156 100644 Binary files a/node_modules/@vercel/ncc/dist/ncc/loaders/ts-loader.js.cache and b/node_modules/@vercel/ncc/dist/ncc/loaders/ts-loader.js.cache differ diff --git a/src/index.ts b/src/index.ts index a01b61e..3767c1d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -31,9 +31,12 @@ async function run() { // `YES`, `1`, etc. or indeed if it can even be `required`), and I want to default to `dry_run` the first time I run // this to avoid accidentally triggering a ton of commits before I get a chance to observe output. const dry_run = !(dry_run_inp == 'false'); + + const token_for_target_repo = core.getInput('token_for_target_repo'); + // Obviously, don't log this! - await main({domain:source_domain, owner:source_owner, name:source_name}, {domain:target_domain, owner:target_owner, name:target_name}, dry_run); + await main({domain:source_domain, owner:source_owner, name:source_name}, {domain:target_domain, owner:target_owner, name:target_name}, dry_run, token_for_target_repo); // Set output core.setOutput('example-output', 'some value'); diff --git a/src/main.ts b/src/main.ts index c13b46b..9f4e1bf 100644 --- a/src/main.ts +++ b/src/main.ts @@ -8,12 +8,16 @@ const WORKING_DIR = './working'; const SOURCE_DIR = WORKING_DIR + '/source'; const TARGET_DIR = WORKING_DIR + '/target'; -export async function main(sourceRepo: Repo, targetRepo: Repo, dryRun: boolean) { +export async function main(sourceRepo: Repo, targetRepo: Repo, dryRun: boolean, tokenForTargetRepo: string) { // It _shouldn't_ ever exist, but it if did, something weird is going on. if (existsSync(WORKING_DIR) || existsSync(SOURCE_DIR) || existsSync(TARGET_DIR)) { throw new Error('Working directory already exists/populated'); } + if (tokenForTargetRepo == '') { + throw new Error('token_for_target_repo is required'); + } + mkdirSync(WORKING_DIR); mkdirSync(SOURCE_DIR); mkdirSync(TARGET_DIR); @@ -114,8 +118,7 @@ export async function main(sourceRepo: Repo, targetRepo: Repo, dryRun: boolean) // // But I'm gonna do a bunch more dry-run testing before I do that! if (!dryRun) { - // TODO - oh, maybe there'll be some authentication problems here? Blech... - execSync(`git push`, { + execSync(`git push https://unused-username:${tokenForTargetRepo}@${targetRepo.domain}/${targetRepo.owner}/${targetRepo.name}`, { cwd: TARGET_DIR }) // TODO - it'd be nice - before this `git push` is probably best - to add a `README.md` comment acknowledging