-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-deploy-script.sh
More file actions
executable file
·73 lines (61 loc) · 1.86 KB
/
Copy pathtest-deploy-script.sh
File metadata and controls
executable file
·73 lines (61 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/bash
# Test script for deploy.sh CI environment detection
echo "Testing deploy.sh CI environment detection..."
# Test 1: Local environment (no CI variables)
echo "=== Test 1: Local environment ==="
unset CI
unset GITHUB_ACTIONS
unset NETLIFY_AUTH_TOKEN
unset NETLIFY_SITE_ID
# Run just the environment detection part
bash -c '
source scripts/deploy.sh 2>/dev/null || true
' | head -5
# Test 2: CI environment with missing variables
echo -e "\n=== Test 2: CI environment with missing variables ==="
export CI=true
export GITHUB_ACTIONS=true
unset NETLIFY_AUTH_TOKEN
unset NETLIFY_SITE_ID
# This should fail with proper error messages
bash -c '
set -e
IS_CI=false
if [ "$CI" = "true" ] || [ "$GITHUB_ACTIONS" = "true" ]; then
IS_CI=true
echo "🤖 Running in CI environment"
fi
if [ "$IS_CI" = "true" ]; then
if [ -z "$NETLIFY_AUTH_TOKEN" ]; then
echo "❌ NETLIFY_AUTH_TOKEN environment variable is required for CI deployment"
echo "💡 Please set NETLIFY_AUTH_TOKEN in your GitHub repository secrets"
exit 1
fi
fi
' 2>&1 || echo "Expected failure - missing NETLIFY_AUTH_TOKEN"
# Test 3: CI environment with variables set
echo -e "\n=== Test 3: CI environment with variables set ==="
export CI=true
export GITHUB_ACTIONS=true
export NETLIFY_AUTH_TOKEN="test-token"
export NETLIFY_SITE_ID="test-site-id"
bash -c '
IS_CI=false
if [ "$CI" = "true" ] || [ "$GITHUB_ACTIONS" = "true" ]; then
IS_CI=true
echo "🤖 Running in CI environment"
fi
if [ "$IS_CI" = "true" ]; then
if [ -z "$NETLIFY_AUTH_TOKEN" ]; then
echo "❌ NETLIFY_AUTH_TOKEN missing"
exit 1
fi
if [ -z "$NETLIFY_SITE_ID" ]; then
echo "❌ NETLIFY_SITE_ID missing"
exit 1
fi
echo "✅ All required CI environment variables are set"
echo "NETLIFY_SITE_ID: $NETLIFY_SITE_ID"
fi
'
echo -e "\n=== Tests completed ==="