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.
pull/729/head
Frostebite 2025-04-14 01:37:55 +01:00
parent db9fc17071
commit 10fc07a79b
3 changed files with 26 additions and 1 deletions

8
dist/index.js generated vendored
View File

@ -4627,6 +4627,14 @@ class RemoteClient {
if (!cloud_runner_1.default.buildParameters.skipLfs) { if (!cloud_runner_1.default.buildParameters.skipLfs) {
try { try {
remote_client_logger_1.RemoteClientLogger.log(`Attempting to pull LFS files with GIT_PRIVATE_TOKEN...`); remote_client_logger_1.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 cloud_runner_system_1.CloudRunnerSystem.Run(`git config --global --replace-all url."https://token:${gitPrivateToken}@github.com/".insteadOf ssh://git@github.com/`);
await cloud_runner_system_1.CloudRunnerSystem.Run(`git config --global --add url."https://token:${gitPrivateToken}@github.com/".insteadOf git@github.com`);
await cloud_runner_system_1.CloudRunnerSystem.Run(`git config --global --add url."https://token:${gitPrivateToken}@github.com/".insteadOf "https://github.com/"`);
await cloud_runner_system_1.CloudRunnerSystem.Run(`git lfs pull`); await cloud_runner_system_1.CloudRunnerSystem.Run(`git lfs pull`);
remote_client_logger_1.RemoteClientLogger.log(`Successfully pulled LFS files with GIT_PRIVATE_TOKEN`); remote_client_logger_1.RemoteClientLogger.log(`Successfully pulled LFS files with GIT_PRIVATE_TOKEN`);
(0, node_console_1.assert)(node_fs_1.default.existsSync(cloud_runner_folders_1.CloudRunnerFolders.lfsFolderAbsolute)); (0, node_console_1.assert)(node_fs_1.default.existsSync(cloud_runner_folders_1.CloudRunnerFolders.lfsFolderAbsolute));

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@ -224,6 +224,23 @@ export class RemoteClient {
if (!CloudRunner.buildParameters.skipLfs) { if (!CloudRunner.buildParameters.skipLfs) {
try { try {
RemoteClientLogger.log(`Attempting to pull LFS files with GIT_PRIVATE_TOKEN...`); 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`); await CloudRunnerSystem.Run(`git lfs pull`);
RemoteClientLogger.log(`Successfully pulled LFS files with GIT_PRIVATE_TOKEN`); RemoteClientLogger.log(`Successfully pulled LFS files with GIT_PRIVATE_TOKEN`);
assert(fs.existsSync(CloudRunnerFolders.lfsFolderAbsolute)); assert(fs.existsSync(CloudRunnerFolders.lfsFolderAbsolute));