mirror of
				https://github.com/actions/checkout.git
				synced 2025-11-01 02:28:40 +08:00 
			
		
		
		
	Add ability to set credential provider for the LFS server
This commit is contained in:
		
							parent
							
								
									5262024a96
								
							
						
					
					
						commit
						fd6a72039b
					
				|  | @ -86,6 +86,10 @@ When Git 2.18 or higher is not in your PATH, falls back to the REST API to downl | ||||||
|     # Default: https://lfscache.office.playeveryware.com/${{ github.repository }} |     # Default: https://lfscache.office.playeveryware.com/${{ github.repository }} | ||||||
|     lfs-url: '' |     lfs-url: '' | ||||||
| 
 | 
 | ||||||
|  |     # Credential provider for the Git-LFS server | ||||||
|  |     # Default: github | ||||||
|  |     lfs-url-cred-provider: '' | ||||||
|  | 
 | ||||||
|     # Whether to checkout submodules: `true` to checkout submodules or `recursive` to |     # Whether to checkout submodules: `true` to checkout submodules or `recursive` to | ||||||
|     # recursively checkout submodules. |     # recursively checkout submodules. | ||||||
|     # |     # | ||||||
|  |  | ||||||
|  | @ -62,6 +62,9 @@ inputs: | ||||||
|   lfs-url: |   lfs-url: | ||||||
|     description: 'URL to use when fetching Git-LFS files' |     description: 'URL to use when fetching Git-LFS files' | ||||||
|     default: 'https://lfscache.office.playeveryware.com/${{ github.repository }}' |     default: 'https://lfscache.office.playeveryware.com/${{ github.repository }}' | ||||||
|  |   lfs-url-cred-provider: | ||||||
|  |     description: 'Credential provider for the Git-LFS server' | ||||||
|  |     default: 'github' | ||||||
|   submodules: |   submodules: | ||||||
|     description: > |     description: > | ||||||
|       Whether to checkout submodules: `true` to checkout submodules or `recursive` to |       Whether to checkout submodules: `true` to checkout submodules or `recursive` to | ||||||
|  |  | ||||||
							
								
								
									
										17
									
								
								dist/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										17
									
								
								dist/index.js
									
									
									
									
										vendored
									
									
								
							|  | @ -18456,6 +18456,7 @@ function getInputs() { | ||||||
|         // LFS
 |         // LFS
 | ||||||
|         result.lfs = (core.getInput('lfs') || 'false').toUpperCase() === 'TRUE'; |         result.lfs = (core.getInput('lfs') || 'false').toUpperCase() === 'TRUE'; | ||||||
|         result.lfsurl = (core.getInput('lfs-url') || ''); |         result.lfsurl = (core.getInput('lfs-url') || ''); | ||||||
|  |         result.lfsCredProvider = (core.getInput('lfs-url-cred-provider') || ''); | ||||||
|         core.debug(`lfs = ${result.lfs}`); |         core.debug(`lfs = ${result.lfs}`); | ||||||
|         // Submodules
 |         // Submodules
 | ||||||
|         result.submodules = false; |         result.submodules = false; | ||||||
|  | @ -31808,6 +31809,7 @@ const path = __importStar(__webpack_require__(622)); | ||||||
| const refHelper = __importStar(__webpack_require__(227)); | const refHelper = __importStar(__webpack_require__(227)); | ||||||
| const stateHelper = __importStar(__webpack_require__(153)); | const stateHelper = __importStar(__webpack_require__(153)); | ||||||
| const urlHelper = __importStar(__webpack_require__(81)); | const urlHelper = __importStar(__webpack_require__(81)); | ||||||
|  | const url_1 = __webpack_require__(835); | ||||||
| function getSource(settings) { | function getSource(settings) { | ||||||
|     return __awaiter(this, void 0, void 0, function* () { |     return __awaiter(this, void 0, void 0, function* () { | ||||||
|         // Repository URL
 |         // Repository URL
 | ||||||
|  | @ -31924,12 +31926,25 @@ function getSource(settings) { | ||||||
|             // LFS URL
 |             // LFS URL
 | ||||||
|             if (settings.lfs && settings.lfsurl) { |             if (settings.lfs && settings.lfsurl) { | ||||||
|                 core.startGroup('Setting LFS URL'); |                 core.startGroup('Setting LFS URL'); | ||||||
|  |                 let remote = new url_1.URL(settings.lfsurl); | ||||||
|  |                 remote.password = core.getInput('token'); | ||||||
|                 yield git |                 yield git | ||||||
|                     .config('lfs.url', settings.lfsurl, false, false) |                     .config('lfs.url', remote.href, false, false) | ||||||
|                     .catch(error => { |                     .catch(error => { | ||||||
|                     core.info(`Failed to initialize safe directory with error: ${error}`); |                     core.info(`Failed to initialize safe directory with error: ${error}`); | ||||||
|                 }); |                 }); | ||||||
|                 core.endGroup(); |                 core.endGroup(); | ||||||
|  |                 if (settings.lfsCredProvider) { | ||||||
|  |                     core.startGroup('Setting LFS credential provider'); | ||||||
|  |                     let url = new url_1.URL(settings.lfsurl); | ||||||
|  |                     let key = 'credential.' + url.host + '.provider'; | ||||||
|  |                     yield git | ||||||
|  |                         .config(key, settings.lfsCredProvider, false, false) | ||||||
|  |                         .catch(error => { | ||||||
|  |                         core.info(`Failed to initialize safe directory with error: ${error}`); | ||||||
|  |                     }); | ||||||
|  |                     core.endGroup(); | ||||||
|  |                 } | ||||||
|             } |             } | ||||||
|             // LFS fetch
 |             // LFS fetch
 | ||||||
|             // Explicit lfs-fetch to avoid slow checkout (fetches one lfs object at a time).
 |             // Explicit lfs-fetch to avoid slow checkout (fetches one lfs object at a time).
 | ||||||
|  |  | ||||||
|  | @ -11,6 +11,7 @@ import * as stateHelper from './state-helper' | ||||||
| import * as urlHelper from './url-helper' | import * as urlHelper from './url-helper' | ||||||
| import {IGitCommandManager} from './git-command-manager' | import {IGitCommandManager} from './git-command-manager' | ||||||
| import {IGitSourceSettings} from './git-source-settings' | import {IGitSourceSettings} from './git-source-settings' | ||||||
|  | import {URL} from "url"; | ||||||
| 
 | 
 | ||||||
| export async function getSource(settings: IGitSourceSettings): Promise<void> { | export async function getSource(settings: IGitSourceSettings): Promise<void> { | ||||||
|   // Repository URL
 |   // Repository URL
 | ||||||
|  | @ -185,14 +186,30 @@ export async function getSource(settings: IGitSourceSettings): Promise<void> { | ||||||
|     // LFS URL
 |     // LFS URL
 | ||||||
|     if (settings.lfs && settings.lfsurl) { |     if (settings.lfs && settings.lfsurl) { | ||||||
|         core.startGroup('Setting LFS URL') |         core.startGroup('Setting LFS URL') | ||||||
|  | 		let remote = new URL(settings.lfsurl) | ||||||
|  | 		remote.password = core.getInput('token') | ||||||
|         await git |         await git | ||||||
|           .config('lfs.url', settings.lfsurl, false, false) |           .config('lfs.url', remote.href, false, false) | ||||||
|           .catch(error => { |           .catch(error => { | ||||||
|             core.info( |             core.info( | ||||||
|               `Failed to initialize safe directory with error: ${error}` |               `Failed to initialize safe directory with error: ${error}` | ||||||
|             ) |             ) | ||||||
|           }) |           }) | ||||||
|         core.endGroup() |         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
 |     // LFS fetch
 | ||||||
|  |  | ||||||
|  | @ -44,6 +44,11 @@ export interface IGitSourceSettings { | ||||||
|    */ |    */ | ||||||
|   lfsurl: string |   lfsurl: string | ||||||
| 
 | 
 | ||||||
|  |   /** | ||||||
|  |    * The credential provider to usse for the Git LFS server | ||||||
|  |    */ | ||||||
|  |   lfsCredProvider: string | ||||||
|  | 
 | ||||||
|   /** |   /** | ||||||
|    * Indicates whether to checkout submodules |    * Indicates whether to checkout submodules | ||||||
|    */ |    */ | ||||||
|  |  | ||||||
|  | @ -92,6 +92,7 @@ export async function getInputs(): Promise<IGitSourceSettings> { | ||||||
|   // LFS
 |   // LFS
 | ||||||
|   result.lfs = (core.getInput('lfs') || 'false').toUpperCase() === 'TRUE' |   result.lfs = (core.getInput('lfs') || 'false').toUpperCase() === 'TRUE' | ||||||
|   result.lfsurl = (core.getInput('lfs-url') || '') |   result.lfsurl = (core.getInput('lfs-url') || '') | ||||||
|  |   result.lfsCredProvider = (core.getInput('lfs-url-cred-provider') || '') | ||||||
|   core.debug(`lfs = ${result.lfs}`) |   core.debug(`lfs = ${result.lfs}`) | ||||||
| 
 | 
 | ||||||
|   // Submodules
 |   // Submodules
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Matthew Endsley
						Matthew Endsley