mirror of
https://github.com/actions/checkout.git
synced 2025-04-20 17:46:45 +00:00
Add ability to set credential provider for the LFS server
This commit is contained in:
parent
5262024a96
commit
fd6a72039b
6 changed files with 47 additions and 2 deletions
|
@ -11,6 +11,7 @@ import * as stateHelper from './state-helper'
|
|||
import * as urlHelper from './url-helper'
|
||||
import {IGitCommandManager} from './git-command-manager'
|
||||
import {IGitSourceSettings} from './git-source-settings'
|
||||
import {URL} from "url";
|
||||
|
||||
export async function getSource(settings: IGitSourceSettings): Promise<void> {
|
||||
// Repository URL
|
||||
|
@ -185,14 +186,30 @@ export async function getSource(settings: IGitSourceSettings): Promise<void> {
|
|||
// LFS URL
|
||||
if (settings.lfs && settings.lfsurl) {
|
||||
core.startGroup('Setting LFS URL')
|
||||
let remote = new URL(settings.lfsurl)
|
||||
remote.password = core.getInput('token')
|
||||
await git
|
||||
.config('lfs.url', settings.lfsurl, false, false)
|
||||
.config('lfs.url', remote.href, false, false)
|
||||
.catch(error => {
|
||||
core.info(
|
||||
`Failed to initialize safe directory with error: ${error}`
|
||||
)
|
||||
})
|
||||
core.endGroup()
|
||||
|
||||
if (settings.lfsCredProvider) {
|
||||
core.startGroup('Setting LFS credential provider')
|
||||
let url = new URL(settings.lfsurl);
|
||||
let key = 'credential.' + url.host + '.provider'
|
||||
await git
|
||||
.config(key, settings.lfsCredProvider, false, false)
|
||||
.catch(error => {
|
||||
core.info(
|
||||
`Failed to initialize safe directory with error: ${error}`
|
||||
)
|
||||
})
|
||||
core.endGroup()
|
||||
}
|
||||
}
|
||||
|
||||
// LFS fetch
|
||||
|
|
|
@ -44,6 +44,11 @@ export interface IGitSourceSettings {
|
|||
*/
|
||||
lfsurl: string
|
||||
|
||||
/**
|
||||
* The credential provider to usse for the Git LFS server
|
||||
*/
|
||||
lfsCredProvider: string
|
||||
|
||||
/**
|
||||
* Indicates whether to checkout submodules
|
||||
*/
|
||||
|
|
|
@ -92,6 +92,7 @@ export async function getInputs(): Promise<IGitSourceSettings> {
|
|||
// LFS
|
||||
result.lfs = (core.getInput('lfs') || 'false').toUpperCase() === 'TRUE'
|
||||
result.lfsurl = (core.getInput('lfs-url') || '')
|
||||
result.lfsCredProvider = (core.getInput('lfs-url-cred-provider') || '')
|
||||
core.debug(`lfs = ${result.lfs}`)
|
||||
|
||||
// Submodules
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue