49 lines
1.5 KiB
YAML
49 lines
1.5 KiB
YAML
name: Fast Submodule Checkout
|
|
description: Updates or clones a submodule much faster by enabling caching
|
|
inputs:
|
|
submodule:
|
|
description: Path to submodule (relative from repo root)
|
|
required: true
|
|
repo:
|
|
description: Path to the repo
|
|
required: false
|
|
outputs: {}
|
|
runs:
|
|
using: composite
|
|
steps:
|
|
- name: Get submodule hash of ${{ inputs.submodule }}
|
|
id: get-submodule-hash
|
|
uses: 0xFEEDC0DE64/get_submodule_hash@main
|
|
with:
|
|
submodule: ${{ inputs.submodule }}
|
|
repo: ${{ inputs.repo }}
|
|
|
|
- name: Cache submodule ${{ inputs.submodule }}
|
|
id: cache-submodule
|
|
uses: actions/cache@v2
|
|
with:
|
|
path: |
|
|
./${{ inputs.repo }}/.git/modules/${{ inputs.submodule }}
|
|
./${{ inputs.repo }}/${{ inputs.submodule }}
|
|
key: ${{ runner.os }}-${{ steps.get-submodule-hash.outputs.hash }}
|
|
|
|
- name: Checkout submodule ${{ inputs.submodule }}
|
|
# GitHub doesnt support if
|
|
#if: steps.cache-submodule.outputs.cache-hit != 'true'
|
|
#run: git submodule update --init --recursive ${{ inputs.submodule }}
|
|
run: |
|
|
if echo ${{ steps.cache-submodule.outputs.cache-hit }} | grep -c "true"
|
|
then
|
|
echo "Cache hit - skipping submodule update"
|
|
else
|
|
if [[ ! -z "${{ inputs.repo }}" ]]
|
|
then
|
|
REPO_ARGS=(-C "${{ inputs.repo }}")
|
|
else
|
|
REPO_ARGS=()
|
|
fi
|
|
|
|
git "${REPO_ARGS[@]}" submodule update --init --recursive ${{ inputs.submodule }}
|
|
fi
|
|
shell: bash
|