mirror of
https://code.forgejo.org/actions/checkout.git
synced 2024-11-23 02:51:20 +01:00
Adds force-api-download option
Signed-off-by: CollinM <collinmcneese@github.com>
This commit is contained in:
parent
e6d535c99c
commit
a24ff48c7b
7 changed files with 23 additions and 3 deletions
|
@ -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
|
# running from unless specified. Example URLs are https://github.com or
|
||||||
# https://my-ghes-server.example.com
|
# https://my-ghes-server.example.com
|
||||||
github-server-url: ''
|
github-server-url: ''
|
||||||
|
|
||||||
|
# Force usage of REST API for downloading ref, even if git is installed locally.
|
||||||
|
# Default: false
|
||||||
|
force-api-download: ''
|
||||||
```
|
```
|
||||||
<!-- end usage -->
|
<!-- end usage -->
|
||||||
|
|
||||||
|
|
|
@ -811,7 +811,8 @@ async function setup(testName: string): Promise<void> {
|
||||||
sshStrict: true,
|
sshStrict: true,
|
||||||
workflowOrganizationId: 123456,
|
workflowOrganizationId: 123456,
|
||||||
setSafeDirectory: true,
|
setSafeDirectory: true,
|
||||||
githubServerUrl: githubServerUrl
|
githubServerUrl: githubServerUrl,
|
||||||
|
forceApiDownload: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,6 +74,10 @@ inputs:
|
||||||
github-server-url:
|
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
|
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
|
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:
|
runs:
|
||||||
using: node16
|
using: node16
|
||||||
main: dist/index.js
|
main: dist/index.js
|
||||||
|
|
5
dist/index.js
vendored
5
dist/index.js
vendored
|
@ -7429,7 +7429,7 @@ function getSource(settings) {
|
||||||
if (isExisting) {
|
if (isExisting) {
|
||||||
yield gitDirectoryHelper.prepareExistingDirectory(git, settings.repositoryPath, repositoryUrl, settings.clean, settings.ref);
|
yield gitDirectoryHelper.prepareExistingDirectory(git, settings.repositoryPath, repositoryUrl, settings.clean, settings.ref);
|
||||||
}
|
}
|
||||||
if (!git) {
|
if (!git || settings.forceApiDownload) {
|
||||||
// Downloading using REST API
|
// Downloading using REST API
|
||||||
core.info(`The repository will be downloaded using the GitHub 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`);
|
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
|
// Determine the GitHub URL that the repository is being hosted from
|
||||||
result.githubServerUrl = core.getInput('github-server-url');
|
result.githubServerUrl = core.getInput('github-server-url');
|
||||||
core.debug(`GitHub Host URL = ${result.githubServerUrl}`);
|
core.debug(`GitHub Host URL = ${result.githubServerUrl}`);
|
||||||
|
// Toggle force-api-download
|
||||||
|
result.forceApiDownload =
|
||||||
|
(core.getInput('force-api-download') || 'false').toUpperCase() === 'TRUE';
|
||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ export async function getSource(settings: IGitSourceSettings): Promise<void> {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!git) {
|
if (!git || settings.forceApiDownload) {
|
||||||
// Downloading using REST API
|
// Downloading using REST API
|
||||||
core.info(`The repository will be downloaded using the GitHub REST API`)
|
core.info(`The repository will be downloaded using the GitHub REST API`)
|
||||||
core.info(
|
core.info(
|
||||||
|
|
|
@ -88,4 +88,9 @@ export interface IGitSourceSettings {
|
||||||
* User override on the GitHub Server/Host URL that hosts the repository to be cloned
|
* User override on the GitHub Server/Host URL that hosts the repository to be cloned
|
||||||
*/
|
*/
|
||||||
githubServerUrl: string | undefined
|
githubServerUrl: string | undefined
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Force the use of API download instead of git commands
|
||||||
|
*/
|
||||||
|
forceApiDownload: boolean
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,5 +130,8 @@ export async function getInputs(): Promise<IGitSourceSettings> {
|
||||||
result.githubServerUrl = core.getInput('github-server-url')
|
result.githubServerUrl = core.getInput('github-server-url')
|
||||||
core.debug(`GitHub Host URL = ${result.githubServerUrl}`)
|
core.debug(`GitHub Host URL = ${result.githubServerUrl}`)
|
||||||
|
|
||||||
|
// Toggle force-api-download
|
||||||
|
result.forceApiDownload =
|
||||||
|
(core.getInput('force-api-download') || 'false').toUpperCase() === 'TRUE'
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue