Skip to content

Commit edc3f1e

Browse files
committed
fix(build): rewrite the submodule URL to include the token directly
1 parent 490c3f9 commit edc3f1e

1 file changed

Lines changed: 15 additions & 20 deletions

File tree

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,22 @@
11
#!/bin/bash
2-
# initialize git submodules during vercel build
2+
set -e
33

4-
set -e # Exit immediately on any error
5-
6-
# Use HTTPS with token if available, otherwise try SSH
74
if [ -n "$GITHUB_TOKEN" ]; then
8-
git config --global credential.helper store
9-
echo "https://${GITHUB_TOKEN}@github.com" > ~/.git-credentials
10-
chmod 600 ~/.git-credentials
11-
echo "Configured git credential helper for GitHub token"
5+
echo "Using HTTPS with GitHub token"
6+
7+
# Overwrite the submodule URL with token-authenticated URL
8+
git submodule set-url apps/web/src/content/newsletters-premium \
9+
https://$GITHUB_TOKEN:@github.com/apsinghdev/opensox-newsletters-premium.git
10+
1211
elif [ -n "$GIT_SSH_KEY" ]; then
13-
# Fallback to SSH if token is not available
14-
mkdir -p ~/.ssh || { echo "Failed to create ~/.ssh directory" >&2; exit 1; }
15-
printf '%s' "$GIT_SSH_KEY" > ~/.ssh/id_ed25519 || { echo "Failed to write SSH key" >&2; exit 1; }
16-
chmod 600 ~/.ssh/id_ed25519 || { echo "Failed to set SSH key permissions" >&2; exit 1; }
17-
ssh-keyscan -t ed25519 github.com >> ~/.ssh/known_hosts 2>/dev/null || true
18-
echo "Configured SSH for private repository access"
12+
echo "Using SSH key authentication"
13+
mkdir -p ~/.ssh
14+
printf '%s' "$GIT_SSH_KEY" > ~/.ssh/id_ed25519
15+
chmod 600 ~/.ssh/id_ed25519
16+
ssh-keyscan github.com >> ~/.ssh/known_hosts
1917
else
20-
echo "Warning: No GITHUB_TOKEN or GIT_SSH_KEY found. Private submodule may fail to clone." >&2
18+
echo "No authentication found!"
2119
fi
2220

23-
# initialize and update submodules
24-
git submodule update --init --recursive --remote
25-
26-
echo "submodules initialized successfully"
27-
21+
git submodule update --init --recursive --force
22+
echo "Submodules initialized successfully"

0 commit comments

Comments
 (0)