27 lines
1.0 KiB
Bash
Executable File
27 lines
1.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
repo_root="$(git rev-parse --show-toplevel)"
|
|
submodule_path="${PROJECT_ATLAS_SUBMODULE_PATH:-portal/src/data/project-atlas}"
|
|
ssh_key="${PROJECT_ATLAS_SSH_PRIVATE_KEY:-}"
|
|
key_file="${RUNNER_TEMP:-/tmp}/project-atlas-submodule-key"
|
|
|
|
# The Project Atlas submodule lives in Gitea and must be fetched with a
|
|
# read-only deploy key stored in PROJECT_ATLAS_SSH_PRIVATE_KEY.
|
|
if git -C "$repo_root" submodule status -- "$submodule_path" | grep -q '^-'; then
|
|
if [[ -z "$ssh_key" ]]; then
|
|
echo "PROJECT_ATLAS_SSH_PRIVATE_KEY is required to initialize the private projectAtlas submodule." >&2
|
|
exit 1
|
|
fi
|
|
|
|
install -d -m 700 "$HOME/.ssh"
|
|
printf '%s\n' "$ssh_key" > "$key_file"
|
|
chmod 600 "$key_file"
|
|
ssh-keyscan -H gitea.d-bis.org >> "$HOME/.ssh/known_hosts"
|
|
|
|
git -C "$repo_root" submodule sync -- "$submodule_path"
|
|
GIT_SSH_COMMAND="ssh -i $key_file -o IdentitiesOnly=yes -o StrictHostKeyChecking=yes" \
|
|
git -C "$repo_root" submodule update --init --recursive -- "$submodule_path"
|
|
fi
|