Skip to content

Commit 9b02250

Browse files
add console debugging
1 parent d54acb7 commit 9b02250

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

.github/workflows/deploy.yml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,14 @@ jobs:
4545
echo "Before injection (showing relevant line):"
4646
grep -n "let webhookUrl = null;" index.html || echo "Pattern not found"
4747
48-
# Create a temporary file with the replacement
49-
awk -v url="$WEBHOOK_URL" '
50-
{
51-
if ($0 ~ /let webhookUrl = null;/) {
52-
print " const webhookUrl = \"" url "\"; // Injected during build"
53-
} else {
54-
print $0
55-
}
56-
}' index.html > index.html.tmp
48+
# Create a temporary file with the exact replacement
49+
sed '/let webhookUrl = null;/c\ const webhookUrl = "'"$WEBHOOK_URL"'"; // Injected by GitHub Actions' index.html > index.html.tmp
50+
51+
echo "Checking if replacement was successful..."
52+
if ! grep -q "Injected by GitHub Actions" index.html.tmp; then
53+
echo "Error: Replacement string not found in temporary file"
54+
exit 1
55+
fi
5756
5857
# Replace the original file
5958
mv index.html.tmp index.html
@@ -62,8 +61,10 @@ jobs:
6261
grep -n "webhookUrl = " index.html | sed 's|https://[^"]*|[WEBHOOK_URL_HIDDEN]|'
6362
6463
echo "Verifying file was modified:"
65-
if grep -q "Injected during build" index.html; then
64+
if grep -q "Injected by GitHub Actions" index.html; then
6665
echo "Webhook URL successfully injected"
66+
echo "Number of lines containing webhookUrl:"
67+
grep -c "webhookUrl" index.html
6768
else
6869
echo "Failed to inject webhook URL"
6970
exit 1

index.html

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,9 @@ <h2>{{title}}</h2>
285285
submitButton.value = 'Sending...';
286286

287287
try {
288+
console.log('Form submission started');
289+
console.log('Current hostname:', window.location.hostname);
290+
288291
// For local development, load from config.json
289292
const getConfigPath = () => {
290293
if (window.location.hostname === 'localhost' ||
@@ -297,22 +300,28 @@ <h2>{{title}}</h2>
297300

298301
// This line will be replaced during build with the actual webhook URL
299302
let webhookUrl = null;
303+
console.log('Initial webhookUrl:', webhookUrl);
300304

301305
// Try to load from config for local development
302306
const configPath = getConfigPath();
307+
console.log('Config path:', configPath);
308+
303309
if (configPath && !webhookUrl) {
304-
console.log('Loading config from:', configPath);
310+
console.log('Attempting to load local config...');
305311
try {
306312
const configResponse = await fetch(configPath);
313+
console.log('Config response:', configResponse.status, configResponse.statusText);
307314
if (configResponse.ok) {
308315
const config = await configResponse.json();
309316
webhookUrl = config.webhookUrl;
317+
console.log('Loaded webhook from config:', !!webhookUrl);
310318
}
311319
} catch (error) {
312320
console.log('Failed to load local config:', error);
313321
}
314322
}
315323

324+
console.log('Final webhookUrl status:', !!webhookUrl);
316325
if (!webhookUrl) {
317326
throw new Error('Contact form is not properly configured. Please try again later.');
318327
}

0 commit comments

Comments
 (0)