Skip to content

Commit 9a2ac98

Browse files
committed
Add Supabase configuration and improve environment variable handling
1 parent 84046ff commit 9a2ac98

File tree

4 files changed

+47
-10
lines changed

4 files changed

+47
-10
lines changed

.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ SERVICE_WORKING_DIR=/path/to/installation/directory
1818
# Supabase configuration
1919
SUPABASE_URL=your-supabase-url
2020
SUPABASE_KEY=your-supabase-api-key
21+
SUPABASE_DB_PASSWORD=your-supabase-database-password
2122

2223
# Mailgun configuration
2324
MAILGUN_API_KEY=your-mailgun-api-key

.github/workflows/deploy.yml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,18 @@ jobs:
7676
# Make scripts executable
7777
chmod +x ./bin/supabase-db.sh
7878
79+
# Debug: Check .env file existence
80+
echo "Checking .env file..."
81+
if [ -f .env ]; then
82+
echo ".env file exists with $(grep -c '' .env) lines"
83+
# Check if required variables are in .env (without showing values)
84+
grep -q "SUPABASE_URL" .env && echo "SUPABASE_URL is set" || echo "SUPABASE_URL is missing"
85+
grep -q "SUPABASE_KEY" .env && echo "SUPABASE_KEY is set" || echo "SUPABASE_KEY is missing"
86+
grep -q "SUPABASE_DB_PASSWORD" .env && echo "SUPABASE_DB_PASSWORD is set" || echo "SUPABASE_DB_PASSWORD is missing"
87+
else
88+
echo ".env file does not exist"
89+
fi
90+
7991
# Setup Supabase project
8092
./bin/supabase-db.sh setup
8193
@@ -84,6 +96,10 @@ jobs:
8496
8597
# Verify installation
8698
supabase --version
99+
env:
100+
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
101+
SUPABASE_KEY: ${{ secrets.SUPABASE_KEY }}
102+
SUPABASE_DB_PASSWORD: ${{ secrets.SUPABASE_DB_PASSWORD }}
87103

88104
- name: Deploy to server with migrations
89105
run: |
@@ -107,4 +123,7 @@ jobs:
107123
DEPLOY_REMOTE_PORT: 2048
108124
DEPLOY_REMOTE_USER: ubuntu
109125
DEPLOY_REMOTE_DIR: www/profullstack.com/pdf
110-
INSTALL_SERVICE: true
126+
INSTALL_SERVICE: true
127+
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
128+
SUPABASE_KEY: ${{ secrets.SUPABASE_KEY }}
129+
SUPABASE_DB_PASSWORD: ${{ secrets.SUPABASE_DB_PASSWORD }}

README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,23 @@ This repository is configured to automatically deploy to the production server w
4141
- Value: Copy the entire content of your .env file
4242
- Click "Add secret"
4343

44-
c. **Server Known Hosts** (as a fallback):
44+
c. **Supabase Configuration**:
45+
- Click "New repository secret"
46+
- Name: `SUPABASE_URL`
47+
- Value: Your Supabase project URL (e.g., https://your-project-ref.supabase.co)
48+
- Click "Add secret"
49+
50+
- Click "New repository secret"
51+
- Name: `SUPABASE_KEY`
52+
- Value: Your Supabase service role API key
53+
- Click "Add secret"
54+
55+
- Click "New repository secret"
56+
- Name: `SUPABASE_DB_PASSWORD`
57+
- Value: Your Supabase database password
58+
- Click "Add secret"
59+
60+
d. **Server Known Hosts** (as a fallback):
4561
- Run this command locally to get the server's SSH key fingerprint (using the correct port):
4662
```bash
4763
ssh-keyscan -p 2048 104.36.23.197

bin/supabase-db.sh

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,19 @@ setup_project() {
6363
export PATH="$HOME/.local/bin:$PATH"
6464
fi
6565

66-
# Load environment variables from .env file
67-
if [ -f .env ]; then
68-
echo -e "${YELLOW}Loading environment variables from .env file...${NC}"
69-
source .env
70-
else
71-
echo -e "${RED}No .env file found. Please create one with SUPABASE_URL, SUPABASE_KEY, and SUPABASE_DB_PASSWORD.${NC}"
72-
exit 1
66+
# Load environment variables from .env file if they're not already set
67+
if [ -z "$SUPABASE_URL" ] || [ -z "$SUPABASE_KEY" ] || [ -z "$SUPABASE_DB_PASSWORD" ]; then
68+
if [ -f .env ]; then
69+
echo -e "${YELLOW}Loading environment variables from .env file...${NC}"
70+
source .env
71+
else
72+
echo -e "${YELLOW}No .env file found. Checking for environment variables...${NC}"
73+
fi
7374
fi
7475

7576
# Check if required environment variables are set
7677
if [ -z "$SUPABASE_URL" ] || [ -z "$SUPABASE_KEY" ] || [ -z "$SUPABASE_DB_PASSWORD" ]; then
77-
echo -e "${RED}Error: SUPABASE_URL, SUPABASE_KEY, and SUPABASE_DB_PASSWORD must be set in .env file.${NC}"
78+
echo -e "${RED}Error: SUPABASE_URL, SUPABASE_KEY, and SUPABASE_DB_PASSWORD must be set either in .env file or as environment variables.${NC}"
7879
exit 1
7980
fi
8081

0 commit comments

Comments
 (0)