Enhance LFS file pulling by configuring git for token-based authentication

- Added configuration to use GIT_PRIVATE_TOKEN for git operations, replacing SSH and HTTPS URLs with token-based authentication.
- Improved error handling to ensure GIT_PRIVATE_TOKEN availability before attempting to pull LFS files.
- This change streamlines the process of pulling LFS files in environments requiring token authentication.
This commit is contained in:
Frostebite 2025-04-14 01:37:55 +01:00
parent db9fc17071
commit 10fc07a79b
3 changed files with 17 additions and 0 deletions

BIN
dist/index.js generated vendored

Binary file not shown.

BIN
dist/index.js.map generated vendored

Binary file not shown.

View File

@ -224,6 +224,23 @@ export class RemoteClient {
if (!CloudRunner.buildParameters.skipLfs) {
try {
RemoteClientLogger.log(`Attempting to pull LFS files with GIT_PRIVATE_TOKEN...`);
// Configure git to use GIT_PRIVATE_TOKEN
const gitPrivateToken = process.env.GIT_PRIVATE_TOKEN;
if (!gitPrivateToken) {
throw new Error('GIT_PRIVATE_TOKEN is not available');
}
await CloudRunnerSystem.Run(
`git config --global --replace-all url."https://token:${gitPrivateToken}@github.com/".insteadOf ssh://git@github.com/`,
);
await CloudRunnerSystem.Run(
`git config --global --add url."https://token:${gitPrivateToken}@github.com/".insteadOf git@github.com`,
);
await CloudRunnerSystem.Run(
`git config --global --add url."https://token:${gitPrivateToken}@github.com/".insteadOf "https://github.com/"`,
);
await CloudRunnerSystem.Run(`git lfs pull`);
RemoteClientLogger.log(`Successfully pulled LFS files with GIT_PRIVATE_TOKEN`);
assert(fs.existsSync(CloudRunnerFolders.lfsFolderAbsolute));