Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support path parameter #44

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ inputs:
description: "Number of commits to fetch. 0 indicates all history for all tags and branches"
required: false
default: 1
path:
description: "Relative path under $GITHUB_WORKSPACE to place the repository"
ref:
description: >
The branch, tag or SHA to checkout. When checking out the repository that
Expand Down Expand Up @@ -66,6 +68,7 @@ runs:
uses: actions/checkout@v3
with:
fetch-depth: ${{ inputs.fetch-depth }}
path: ${{ inputs.path }}
ref: ${{ inputs.ref }}
repository: ${{ inputs.repository }}
token: ${{ inputs.token }}
Expand All @@ -74,6 +77,7 @@ runs:

- name: Create LFS file list
run: |
cd "${{ inputs.path || '.' }}"
git lfs ls-files --long --include "${{ inputs.include }}" --exclude "${{ inputs.exclude }}" | cut -d ' ' -f1 > .lfs-assets-id-unsorted
git submodule foreach git lfs ls-files --long --include "${{ inputs.include }}" --exclude "${{ inputs.exclude }}" | cut -d ' ' -f1 >> .lfs-assets-id-unsorted
cat .lfs-assets-id-unsorted | sort > .lfs-assets-id
Expand All @@ -87,8 +91,8 @@ runs:
# `git config` is used to extract the `path` value for each git submodule
# for more information about the .gitmodules file, see: https://git-scm.com/docs/gitmodules
while read line; do
CACHE_PATHS+=".git/modules/$line/lfs "
done < <(git config --file .gitmodules --get-regexp path | awk '{ print $2 }')
CACHE_PATHS+="${{ inputs.path || '.' }}/.git/modules/$line/lfs "
done < <(git -C "${{ inputs.path || '.' }}" config --file .gitmodules --get-regexp path | awk '{ print $2 }')

echo "CACHE_PATHS=$CACHE_PATHS" >> $GITHUB_OUTPUT
id: cache-paths
Expand All @@ -99,20 +103,22 @@ runs:
id: lfs-cache
with:
path: |
.git/lfs
${{ inputs.path || '.' }}/.git/lfs
${{ steps.cache-paths.outputs.CACHE_PATHS }}
key: lfs-${{ hashFiles('.lfs-assets-id') }}-v2
key: lfs-${{ hashFiles(format('{0}/.lfs-assets-id', inputs.path || '.')) }}-v2
enableCrossOsArchive: ${{ inputs.enableCrossOsArchive }}

- name: Git LFS Pull
run: |
cd "${{ inputs.path || '.' }}"
git lfs pull --include "${{ inputs.include }}" --exclude "${{ inputs.exclude }}"
git submodule foreach git lfs pull --include "${{ inputs.include }}" --exclude "${{ inputs.exclude }}"
shell: bash

# Don't leave behind temp files in case build system checks for dirty workspace
- name: Cleanup Temp Files
run: |
cd "${{ inputs.path || '.' }}"
rm .lfs-assets-id-unsorted
rm .lfs-assets-id
shell: bash