Add the ability to setup a caching git-lfs proxy server

This commit is contained in:
Matthew Endsley 2022-10-11 16:52:31 -07:00
parent 1f9a0c22da
commit 5262024a96
6 changed files with 2391 additions and 2354 deletions

174
README.md
View file

@ -17,91 +17,95 @@ When Git 2.18 or higher is not in your PATH, falls back to the REST API to downl
# Usage # Usage
<!-- start usage --> <!-- start usage -->
```yaml ```yaml
- uses: actions/checkout@v3 - uses: actions/checkout@v3
with: with:
# Repository name with owner. For example, actions/checkout # Repository name with owner. For example, actions/checkout
# Default: ${{ github.repository }} # Default: ${{ github.repository }}
repository: '' repository: ''
# The branch, tag or SHA to checkout. When checking out the repository that # The branch, tag or SHA to checkout. When checking out the repository that
# triggered a workflow, this defaults to the reference or SHA for that event. # triggered a workflow, this defaults to the reference or SHA for that event.
# Otherwise, uses the default branch. # Otherwise, uses the default branch.
ref: '' ref: ''
# Personal access token (PAT) used to fetch the repository. The PAT is configured # Personal access token (PAT) used to fetch the repository. The PAT is configured
# with the local git config, which enables your scripts to run authenticated git # with the local git config, which enables your scripts to run authenticated git
# commands. The post-job step removes the PAT. # commands. The post-job step removes the PAT.
# #
# We recommend using a service account with the least permissions necessary. Also # We recommend using a service account with the least permissions necessary. Also
# when generating a new PAT, select the least scopes necessary. # when generating a new PAT, select the least scopes necessary.
# #
# [Learn more about creating and using encrypted secrets](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets) # [Learn more about creating and using encrypted secrets](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets)
# #
# Default: ${{ github.token }} # Default: ${{ github.token }}
token: '' token: ''
# SSH key used to fetch the repository. The SSH key is configured with the local # SSH key used to fetch the repository. The SSH key is configured with the local
# git config, which enables your scripts to run authenticated git commands. The # git config, which enables your scripts to run authenticated git commands. The
# post-job step removes the SSH key. # post-job step removes the SSH key.
# #
# We recommend using a service account with the least permissions necessary. # We recommend using a service account with the least permissions necessary.
# #
# [Learn more about creating and using encrypted secrets](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets) # [Learn more about creating and using encrypted secrets](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets)
ssh-key: '' ssh-key: ''
# Known hosts in addition to the user and global host key database. The public SSH # Known hosts in addition to the user and global host key database. The public SSH
# keys for a host may be obtained using the utility `ssh-keyscan`. For example, # keys for a host may be obtained using the utility `ssh-keyscan`. For example,
# `ssh-keyscan github.com`. The public key for github.com is always implicitly # `ssh-keyscan github.com`. The public key for github.com is always implicitly
# added. # added.
ssh-known-hosts: '' ssh-known-hosts: ''
# Whether to perform strict host key checking. When true, adds the options # Whether to perform strict host key checking. When true, adds the options
# `StrictHostKeyChecking=yes` and `CheckHostIP=no` to the SSH command line. Use # `StrictHostKeyChecking=yes` and `CheckHostIP=no` to the SSH command line. Use
# the input `ssh-known-hosts` to configure additional hosts. # the input `ssh-known-hosts` to configure additional hosts.
# Default: true # Default: true
ssh-strict: '' ssh-strict: ''
# Whether to configure the token or SSH key with the local git config # Whether to configure the token or SSH key with the local git config
# Default: true # Default: true
persist-credentials: '' persist-credentials: ''
# Relative path under $GITHUB_WORKSPACE to place the repository # Relative path under $GITHUB_WORKSPACE to place the repository
path: '' path: ''
# Whether to execute `git clean -ffdx && git reset --hard HEAD` before fetching # Whether to execute `git clean -ffdx && git reset --hard HEAD` before fetching
# Default: true # Default: true
clean: '' clean: ''
# Number of commits to fetch. 0 indicates all history for all branches and tags. # Number of commits to fetch. 0 indicates all history for all branches and tags.
# Default: 1 # Default: 1
fetch-depth: '' fetch-depth: ''
# Whether to download Git-LFS files # Whether to download Git-LFS files
# Default: false # Default: false
lfs: '' lfs: ''
# Whether to checkout submodules: `true` to checkout submodules or `recursive` to # URL to use when fetching Git-LFS files
# recursively checkout submodules. # Default: https://lfscache.office.playeveryware.com/${{ github.repository }}
# lfs-url: ''
# When the `ssh-key` input is not provided, SSH URLs beginning with
# `git@github.com:` are converted to HTTPS. # Whether to checkout submodules: `true` to checkout submodules or `recursive` to
# # recursively checkout submodules.
# Default: false #
submodules: '' # When the `ssh-key` input is not provided, SSH URLs beginning with
# `git@github.com:` are converted to HTTPS.
# Add repository path as safe.directory for Git global config by running `git #
# config --global --add safe.directory <path>` # Default: false
# Default: true submodules: ''
set-safe-directory: ''
# Add repository path as safe.directory for Git global config by running `git
# The base URL for the GitHub instance that you are trying to clone from, will use # config --global --add safe.directory <path>`
# environment defaults to fetch from the same instance that the workflow is # Default: true
# running from unless specified. Example URLs are https://github.com or set-safe-directory: ''
# https://my-ghes-server.example.com
github-server-url: '' # 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
github-server-url: ''
```
<!-- end usage --> <!-- end usage -->
# Scenarios # Scenarios

View file

@ -59,6 +59,9 @@ inputs:
lfs: lfs:
description: 'Whether to download Git-LFS files' description: 'Whether to download Git-LFS files'
default: false default: false
lfs-url:
description: 'URL to use when fetching Git-LFS files'
default: 'https://lfscache.office.playeveryware.com/${{ github.repository }}'
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

4549
dist/index.js vendored

File diff suppressed because it is too large Load diff

View file

@ -182,6 +182,19 @@ export async function getSource(settings: IGitSourceSettings): Promise<void> {
) )
core.endGroup() core.endGroup()
// LFS URL
if (settings.lfs && settings.lfsurl) {
core.startGroup('Setting LFS URL')
await git
.config('lfs.url', settings.lfsurl, 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).
// Explicit lfs fetch will fetch lfs objects in parallel. // Explicit lfs fetch will fetch lfs objects in parallel.

View file

@ -39,6 +39,11 @@ export interface IGitSourceSettings {
*/ */
lfs: boolean lfs: boolean
/**
* The fetch URL to use for LFS objects
*/
lfsurl: string
/** /**
* Indicates whether to checkout submodules * Indicates whether to checkout submodules
*/ */

View file

@ -91,6 +91,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') || '')
core.debug(`lfs = ${result.lfs}`) core.debug(`lfs = ${result.lfs}`)
// Submodules // Submodules