Add option repo

This commit is contained in:
2021-09-18 23:25:13 +02:00
committed by GitHub
parent 8f4acda744
commit 092c100afe

View File

@@ -4,6 +4,9 @@ inputs:
submodule: submodule:
description: Path to submodule (relative from repo root) description: Path to submodule (relative from repo root)
required: true required: true
repo:
description: Path to the repo
required: false
outputs: outputs:
hash: hash:
description: The hash of the submodule description: The hash of the submodule
@@ -13,12 +16,28 @@ runs:
steps: steps:
- id: get-submodule-hash - id: get-submodule-hash
run: | run: |
SUBMODULE_HASH="$(git submodule | awk '{ if ($2 == "${{ inputs.submodule }}") print $1 }')" if [[ ! -z "${{ inputs.repo }}" ]]
then
REPO_ARGS="-C \"${{ inputs.repo }}\""
else
REPO_ARGS=""
fi
SUBMODULES="$(git $REPO_ARGS submodule)"
if [[ $? -ne 0 ]]
then
echo ERROR git submodule failed
echo "$SUBMODULES"
exit 1
fi
SUBMODULE_HASH="$(echo "$SUBMODULES" | awk '{ if ($2 == "${{ inputs.submodule }}") print $1 }')"
if [[ -z "${SUBMODULE_HASH}" ]] if [[ -z "${SUBMODULE_HASH}" ]]
then then
echo ERROR: could not get hash for submodule ${{ inputs.submodule }} echo ERROR: could not get hash for submodule ${{ inputs.submodule }}
git submodule git submodule
exit 1 exit 1
fi fi
echo "::set-output name=hash::${SUBMODULE_HASH#"-"}" echo "::set-output name=hash::${SUBMODULE_HASH#"-"}"
shell: bash shell: bash