Skip to content

Commit d6c3b5c

Browse files
committed
Better output
1 parent d76cb1f commit d6c3b5c

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

src/check-site-url.sh

+9-6
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,19 @@ check_site_url() {
1919
# If config/hyde.php exists, check if it has a non-localhost URL
2020
if [ -f "config/hyde.php" ]; then
2121
# Look for url configuration line and exclude localhost
22-
if grep -q "'url' => env('SITE_URL'," config/hyde.php && \
23-
! grep -q "'url' => env('SITE_URL', 'http://localhost')," config/hyde.php; then
24-
return 0
22+
if grep -q "'url' => env('SITE_URL'," config/hyde.php; then
23+
line_number=$(grep -n "'url' => env('SITE_URL'," config/hyde.php | cut -d: -f1)
24+
if ! grep -q "'url' => env('SITE_URL', 'http://localhost')," config/hyde.php; then
25+
return 0
26+
fi
27+
echo "::warning file=config/hyde.php,line=$line_number,title=Missing Site URL::The site URL is set to localhost in your configuration file. Consider setting a production URL."
28+
return 1
2529
fi
2630
fi
2731

32+
echo "::warning title=Missing Site URL::No SITE_URL environment variable found. It's recommended to set a production URL for your site. You can set it using the 'env' input with 'SITE_URL=https://example.com'"
2833
return 1
2934
}
3035

3136
# Show warning if SITE_URL is not properly set
32-
if ! check_site_url; then
33-
echo "::warning::No SITE_URL environment variable found. It's recommended to set a production URL for your site. You can set it using the 'env' input with 'SITE_URL=https://example.com'"
34-
fi
37+
check_site_url

tests/unit/test-check-site-url.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ test_site_url_warnings() {
88
# Test case 1: No SITE_URL set anywhere
99
touch .env
1010
output=$(bash "$base_dir/src/check-site-url.sh")
11-
expected="::warning::No SITE_URL environment variable found. It's recommended to set a production URL for your site. You can set it using the 'env' input with 'SITE_URL=https://example.com'"
11+
expected="::warning title=Missing Site URL::No SITE_URL environment variable found. It's recommended to set a production URL for your site. You can set it using the 'env' input with 'SITE_URL=https://example.com'"
1212

1313
if [[ "$output" != "$expected" ]]; then
1414
echo "Test 1 failed: Warning not shown when SITE_URL is missing"
@@ -50,6 +50,7 @@ test_site_url_warnings() {
5050
# Test case 4: SITE_URL in config but with localhost
5151
echo "'url' => env('SITE_URL', 'http://localhost')," > config/hyde.php
5252
output=$(bash "$base_dir/src/check-site-url.sh")
53+
expected="::warning file=config/hyde.php,line=1,title=Missing Site URL::The site URL is set to localhost in your configuration file. Consider setting a production URL."
5354

5455
if [[ "$output" != "$expected" ]]; then
5556
echo "Test 4 failed: Warning not shown when SITE_URL is localhost"

0 commit comments

Comments
 (0)