Skip to content

Commit 10fc07a

Browse files
committed
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.
1 parent db9fc17 commit 10fc07a

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

dist/index.js

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/model/cloud-runner/remote-client/index.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,23 @@ export class RemoteClient {
224224
if (!CloudRunner.buildParameters.skipLfs) {
225225
try {
226226
RemoteClientLogger.log(`Attempting to pull LFS files with GIT_PRIVATE_TOKEN...`);
227+
228+
// Configure git to use GIT_PRIVATE_TOKEN
229+
const gitPrivateToken = process.env.GIT_PRIVATE_TOKEN;
230+
if (!gitPrivateToken) {
231+
throw new Error('GIT_PRIVATE_TOKEN is not available');
232+
}
233+
234+
await CloudRunnerSystem.Run(
235+
`git config --global --replace-all url."https://token:${gitPrivateToken}@github.com/".insteadOf ssh://git@github.com/`,
236+
);
237+
await CloudRunnerSystem.Run(
238+
`git config --global --add url."https://token:${gitPrivateToken}@github.com/".insteadOf git@github.com`,
239+
);
240+
await CloudRunnerSystem.Run(
241+
`git config --global --add url."https://token:${gitPrivateToken}@github.com/".insteadOf "https://github.com/"`,
242+
);
243+
227244
await CloudRunnerSystem.Run(`git lfs pull`);
228245
RemoteClientLogger.log(`Successfully pulled LFS files with GIT_PRIVATE_TOKEN`);
229246
assert(fs.existsSync(CloudRunnerFolders.lfsFolderAbsolute));

0 commit comments

Comments
 (0)