Skip to content

Commit d6399e3

Browse files
committed
fix: remove global disabling of set -e
1 parent ba63be5 commit d6399e3

1 file changed

Lines changed: 25 additions & 2 deletions

File tree

apps/web/scripts/init-submodules.sh

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,43 @@ set -e
33

44
if [ -n "$GITHUB_TOKEN" ]; then
55
echo "Using HTTPS with GitHub token"
6+
7+
# Verify token is not empty after trimming
8+
if [ -z "${GITHUB_TOKEN// }" ]; then
9+
echo "Error: GITHUB_TOKEN is set but empty"
10+
exit 1
11+
fi
612

713
# Overwrite the submodule URL with token-authenticated URL
814
git submodule set-url apps/web/src/content/newsletters-premium \
915
https://$GITHUB_TOKEN:@github.com/apsinghdev/opensox-newsletters-premium.git
1016

1117
elif [ -n "$GIT_SSH_KEY" ]; then
1218
echo "Using SSH key authentication"
19+
20+
if [ -z "${GIT_SSH_KEY// }" ]; then
21+
echo "Error: GIT_SSH_KEY is set but empty"
22+
exit 1
23+
fi
24+
25+
if ! echo "$GIT_SSH_KEY" | grep -qE "^(ssh-ed25519|ssh-rsa|ecdsa-sha2-nistp256|ecdsa-sha2-nistp384|ecdsa-sha2-nistp521|-----BEGIN)"; then
26+
echo "Error: GIT_SSH_KEY does not appear to be a valid SSH key"
27+
exit 1
28+
fi
29+
1330
mkdir -p ~/.ssh
1431
printf '%s' "$GIT_SSH_KEY" > ~/.ssh/id_ed25519
1532
chmod 600 ~/.ssh/id_ed25519
1633
ssh-keyscan github.com >> ~/.ssh/known_hosts
34+
1735
else
1836
echo "No authentication found!"
1937
fi
2038

21-
git submodule update --init --recursive --force
22-
echo "Submodules initialized successfully"
39+
if git submodule update --init --recursive --force; then
40+
echo "Submodules initialized successfully"
41+
else
42+
echo "Warning: Submodule initialization failed, but continuing build..."
43+
echo "Note: Public newsletters will still work. Premium newsletters require authentication."
44+
exit 0
45+
fi

0 commit comments

Comments
 (0)