Files
get_submodule_hash/action.yml
T

43 lines
1.1 KiB
YAML
Raw Normal View History

2021-09-18 22:36:19 +02:00
name: Get submodule hash
description: Tries to acquire the hash of a submodule
inputs:
submodule:
description: Path to submodule (relative from repo root)
required: true
2021-09-18 23:25:13 +02:00
repo:
description: Path to the repo
required: false
2021-09-18 22:36:19 +02:00
outputs:
hash:
description: The hash of the submodule
value: ${{ steps.get-submodule-hash.outputs.hash }}
runs:
using: composite
steps:
- id: get-submodule-hash
run: |
2021-09-18 23:25:13 +02:00
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 }')"
2021-09-18 22:36:19 +02:00
if [[ -z "${SUBMODULE_HASH}" ]]
then
echo ERROR: could not get hash for submodule ${{ inputs.submodule }}
git submodule
exit 1
fi
2021-09-18 23:25:13 +02:00
2021-09-18 22:36:19 +02:00
echo "::set-output name=hash::${SUBMODULE_HASH#"-"}"
shell: bash