forked from mgmonteleone/py-dev-rev
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup-github-secrets.sh
More file actions
executable file
Β·137 lines (120 loc) Β· 3.7 KB
/
Copy pathsetup-github-secrets.sh
File metadata and controls
executable file
Β·137 lines (120 loc) Β· 3.7 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#!/bin/bash
# Setup GitHub Secrets for Integration Tests
# This script helps you configure GitHub Actions to run integration tests
set -e
echo "π GitHub Secrets Setup for DevRev SDK"
echo "========================================"
echo ""
# Check if gh CLI is installed
if ! command -v gh &> /dev/null; then
echo "β GitHub CLI (gh) is not installed."
echo ""
echo "Install it with:"
echo " macOS: brew install gh"
echo " Linux: See https://github.com/cli/cli#installation"
echo " Windows: See https://github.com/cli/cli#installation"
echo ""
exit 1
fi
# Check if authenticated
if ! gh auth status &> /dev/null; then
echo "β Not authenticated with GitHub CLI."
echo ""
echo "Run: gh auth login"
echo ""
exit 1
fi
echo "β
GitHub CLI is installed and authenticated"
echo ""
# Check if .env file exists
if [ ! -f .env ]; then
echo "β οΈ No .env file found."
echo ""
echo "Would you like to:"
echo " 1. Enter API token manually"
echo " 2. Exit and create .env file first"
echo ""
read -p "Choice (1 or 2): " choice
if [ "$choice" = "2" ]; then
echo ""
echo "Create a .env file with:"
echo " cp .env.sample .env"
echo " # Edit .env and add your DEVREV_API_TOKEN"
echo ""
exit 0
fi
echo ""
read -sp "Enter your DevRev API token: " api_token
echo ""
else
# Try to read from .env
if grep -q "^DEVREV_API_TOKEN=" .env; then
api_token=$(grep "^DEVREV_API_TOKEN=" .env | cut -d'=' -f2-)
# Check if it's the placeholder
if [ "$api_token" = "your-api-token-here" ] || [ -z "$api_token" ]; then
echo "β οΈ .env file exists but DEVREV_API_TOKEN is not set."
echo ""
read -sp "Enter your DevRev API token: " api_token
echo ""
else
echo "β
Found DEVREV_API_TOKEN in .env file"
echo ""
read -p "Use this token for GitHub secret? (y/n): " use_env
if [ "$use_env" != "y" ]; then
echo ""
read -sp "Enter your DevRev API token: " api_token
echo ""
fi
fi
else
echo "β οΈ .env file exists but DEVREV_API_TOKEN is not set."
echo ""
read -sp "Enter your DevRev API token: " api_token
echo ""
fi
fi
# Validate token is not empty
if [ -z "$api_token" ]; then
echo "β API token cannot be empty"
exit 1
fi
# Validate token format (basic check - should start with "ey" for JWT)
if [[ ! "$api_token" =~ ^ey ]]; then
echo "β οΈ Warning: Token doesn't look like a valid JWT (should start with 'ey')"
read -p "Continue anyway? (y/n): " continue
if [ "$continue" != "y" ]; then
exit 1
fi
fi
echo ""
echo "π€ Setting GitHub secret DEVREV_API_TOKEN..."
# Set the secret
if gh secret set DEVREV_API_TOKEN --body "$api_token"; then
echo "β
Secret DEVREV_API_TOKEN set successfully!"
else
echo "β Failed to set secret"
exit 1
fi
echo ""
echo "π Verifying secret was set..."
if gh secret list | grep -q "DEVREV_API_TOKEN"; then
echo "β
Secret verified!"
else
echo "β Secret not found in list"
exit 1
fi
echo ""
echo "β
Setup Complete!"
echo ""
echo "Next steps:"
echo " 1. Push a commit to trigger CI workflow"
echo " 2. Check GitHub Actions tab to see integration tests run"
echo " 3. Integration tests will run automatically on:"
echo " - Every push to main"
echo " - Every pull request"
echo " - Daily at 6 AM UTC (scheduled)"
echo ""
echo "To test locally:"
echo " export DEVREV_API_TOKEN=\"\$api_token\""
echo " pytest tests/integration/ -v -m integration"
echo ""