Skip to content

Commit 894fe90

Browse files
authored
Merge pull request #206 from apsinghdev/fix/build-ssh
[fix] fix ssh errors
2 parents a87627a + edc3f1e commit 894fe90

3 files changed

Lines changed: 29 additions & 15 deletions

File tree

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[submodule "apps/web/src/content/newsletters-premium"]
22
path = apps/web/src/content/newsletters-premium
3-
url = git@github.com:apsinghdev/opensox-newsletters-premium.git
3+
url = https://github.com/apsinghdev/opensox-newsletters-premium.git
Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
#!/bin/bash
2-
# initialize git submodules during vercel build
2+
set -e
33

4-
set -e # Exit immediately on any error
4+
if [ -n "$GITHUB_TOKEN" ]; then
5+
echo "Using HTTPS with GitHub token"
56

6-
# setup ssh for private submodule
7-
if [ -n "$GIT_SSH_KEY" ]; then
8-
mkdir -p ~/.ssh || { echo "Failed to create ~/.ssh directory" >&2; exit 1; }
9-
printf '%s' "$GIT_SSH_KEY" > ~/.ssh/id_ed25519 || { echo "Failed to write SSH key" >&2; exit 1; }
10-
chmod 600 ~/.ssh/id_ed25519 || { echo "Failed to set SSH key permissions" >&2; exit 1; }
11-
ssh-keyscan -t ed25519 github.com >> ~/.ssh/known_hosts 2>/dev/null || true
12-
fi
13-
14-
# initialize and update submodules
15-
git submodule update --init --recursive --remote
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
1610

17-
echo "submodules initialized successfully"
11+
elif [ -n "$GIT_SSH_KEY" ]; then
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
17+
else
18+
echo "No authentication found!"
19+
fi
1820

21+
git submodule update --init --recursive --force
22+
echo "Submodules initialized successfully"

turbo.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,17 @@
55
"build": {
66
"dependsOn": ["^build"],
77
"inputs": ["$TURBO_DEFAULT$", ".env*"],
8-
"outputs": [".next/**", "!.next/cache/**", "dist/**"]
8+
"outputs": [".next/**", "!.next/cache/**", "dist/**"],
9+
"env": [
10+
"GITHUB_TOKEN",
11+
"GIT_SSH_KEY",
12+
"NEXTAUTH_SECRET",
13+
"GOOGLE_CLIENT_ID",
14+
"GOOGLE_CLIENT_SECRET",
15+
"NEXTAUTH_URL",
16+
"GITHUB_CLIENT_ID",
17+
"GITHUB_CLIENT_SECRET"
18+
]
919
},
1020
"lint": {
1121
"dependsOn": ["^lint"]

0 commit comments

Comments
 (0)