1
0
Fork 0
mirror of https://github.com/actions/checkout synced 2024-11-09 23:22:40 +00:00

Adds force-api-download option

Signed-off-by: CollinM <collinmcneese@github.com>
This commit is contained in:
CollinM 2022-10-01 06:48:13 -05:00
parent e6d535c99c
commit a24ff48c7b
No known key found for this signature in database
GPG key ID: 6C1C8E02FD10FBA1
7 changed files with 23 additions and 3 deletions

View file

@ -103,6 +103,10 @@ When Git 2.18 or higher is not in your PATH, falls back to the REST API to downl
# running from unless specified. Example URLs are https://github.com or
# https://my-ghes-server.example.com
github-server-url: ''
# Force usage of REST API for downloading ref, even if git is installed locally.
# Default: false
force-api-download: ''
```
<!-- end usage -->

View file

@ -811,7 +811,8 @@ async function setup(testName: string): Promise<void> {
sshStrict: true,
workflowOrganizationId: 123456,
setSafeDirectory: true,
githubServerUrl: githubServerUrl
githubServerUrl: githubServerUrl,
forceApiDownload: false
}
}

View file

@ -74,6 +74,10 @@ inputs:
github-server-url:
description: The base URL for the GitHub instance that you are trying to clone from, will use environment defaults to fetch from the same instance that the workflow is running from unless specified. Example URLs are https://github.com or https://my-ghes-server.example.com
required: false
force-api-download:
description: Force usage of REST API for downloading ref, even if git is installed locally.
required: false
default: false
runs:
using: node16
main: dist/index.js

5
dist/index.js vendored
View file

@ -7429,7 +7429,7 @@ function getSource(settings) {
if (isExisting) {
yield gitDirectoryHelper.prepareExistingDirectory(git, settings.repositoryPath, repositoryUrl, settings.clean, settings.ref);
}
if (!git) {
if (!git || settings.forceApiDownload) {
// Downloading using REST API
core.info(`The repository will be downloaded using the GitHub REST API`);
core.info(`To create a local Git repository instead, add Git ${gitCommandManager.MinimumGitVersion} or higher to the PATH`);
@ -17390,6 +17390,9 @@ function getInputs() {
// Determine the GitHub URL that the repository is being hosted from
result.githubServerUrl = core.getInput('github-server-url');
core.debug(`GitHub Host URL = ${result.githubServerUrl}`);
// Toggle force-api-download
result.forceApiDownload =
(core.getInput('force-api-download') || 'false').toUpperCase() === 'TRUE';
return result;
});
}

View file

@ -71,7 +71,7 @@ export async function getSource(settings: IGitSourceSettings): Promise<void> {
)
}
if (!git) {
if (!git || settings.forceApiDownload) {
// Downloading using REST API
core.info(`The repository will be downloaded using the GitHub REST API`)
core.info(

View file

@ -88,4 +88,9 @@ export interface IGitSourceSettings {
* User override on the GitHub Server/Host URL that hosts the repository to be cloned
*/
githubServerUrl: string | undefined
/**
* Force the use of API download instead of git commands
*/
forceApiDownload: boolean
}

View file

@ -130,5 +130,8 @@ export async function getInputs(): Promise<IGitSourceSettings> {
result.githubServerUrl = core.getInput('github-server-url')
core.debug(`GitHub Host URL = ${result.githubServerUrl}`)
// Toggle force-api-download
result.forceApiDownload =
(core.getInput('force-api-download') || 'false').toUpperCase() === 'TRUE'
return result
}