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
parent
db9fc17071
commit
10fc07a79b
|
@ -4627,6 +4627,14 @@ class RemoteClient {
|
|||
if (!cloud_runner_1.default.buildParameters.skipLfs) {
|
||||
try {
|
||||
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`);
|
||||
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));
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -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));
|
||||
|
|
Loading…
Reference in New Issue