fregante / ghat

🛕 Reuse GitHub Actions workflows across repositories
https://npm.im/ghat
MIT License
264 stars 9 forks source link

Private repositories #24

Open cjyar opened 3 years ago

cjyar commented 3 years ago

Is there a way to fetch templates from a private repo? Is it possible to do so from a batch process? I saw #2 mentioned this, but it looks like that ticket was closed without being implemented.

cjyar commented 3 years ago

Degit appears to fetch via https, so I tried this workaround:

git config --global credential.helper store
echo https://foo:${PAT}@github.com > ~/.git-credentials
npx ghat user/repo/file.yaml

(I also tried with --mode=git.)

With this config, ghat didn't prompt for credentials. The output I received was:

(node:8523) UnhandledPromiseRejectionWarning: Error: could not download https://github.com/user/repo/archive/deadbeefdeadbeef.tar.gz
    at Degit._cloneWithTar (/root/.npm/_npx/8523/lib/node_modules/ghat/dist/index.js:15361:10)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async Degit.clone (/root/.npm/_npx/8523/lib/node_modules/ghat/dist/index.js:15157:4)
    at async ghat (/root/.npm/_npx/8523/lib/node_modules/ghat/dist/index.js:190:2)
    at async /root/.npm/_npx/8523/lib/node_modules/ghat/dist/index.js:31:4
(Use `node --trace-warnings ...` to show where the warning was created)
(node:8523) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:8523) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

I think this means that ghat ignores the unknown --mode flag, and degit isn't able to clone the private repo via HTTPS, even though it receives credentials from Git.

cjyar commented 3 years ago

Not sure if this is useful, but it looks like degit has a fork that's more actively maintained: Rich-Harris/degit#258.