Plumb-through token

This commit is contained in:
Jack Jackson 2025-03-01 23:08:34 -08:00
parent af8aa50f6b
commit a6ace8f4c6
9 changed files with 21 additions and 9 deletions

View File

@ -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"

12
dist/index.js vendored
View File

@ -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

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -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');

View File

@ -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