Skip to content

Commit d57f21c

Browse files
committed
workflow worked but resulted in supabase issues
1 parent 31a2af3 commit d57f21c

2 files changed

Lines changed: 76 additions & 43 deletions

File tree

.github/workflows/build_windows.yaml

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,6 @@ jobs:
88
steps:
99
- name: Checkout code
1010
uses: actions/checkout@v4
11-
12-
- name: Create .env file
13-
run: |
14-
echo "SUPABASE_URL=${{ secrets.SUPABASE_URL }}" > .env
15-
echo "SUPABASE_KEY=${{ secrets.SUPABASE_KEY }}" >> .env
16-
type .env # For debugging (optional)
1711

1812
- name: Setup Flutter
1913
uses: subosito/flutter-action@v2
@@ -24,18 +18,37 @@ jobs:
2418
- name: Install dependencies
2519
run: flutter pub get
2620

21+
- name: Create .env file
22+
run: |
23+
echo "SUPABASE_URL=${{ secrets.SUPABASE_URL }}" > .env
24+
echo "SUPABASE_KEY=${{ secrets.SUPABASE_KEY }}" >> .env
25+
type .env # For debugging (optional)
26+
2727
- name: Build Windows EXE
28-
run: flutter build windows --release
29-
28+
run: |
29+
flutter build windows --release
30+
env:
31+
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
32+
SUPABASE_KEY: ${{ secrets.SUPABASE_KEY }}
33+
3034
- name: Activate Fastforge
3135
run: dart pub global activate fastforge
32-
36+
3337
- name: Package using Fastforge
34-
run: fastforge package --platform windows --targets exe
38+
run: |
39+
fastforge package --platform windows --targets exe
40+
working-directory: build/windows/x64/release # Adjust based on your Flutter output
3541

3642
- name: Upload Artifact
3743
uses: actions/upload-artifact@v4
3844
with:
3945
name: WindowsExecutable
4046
path: dist/0.1.0/cookethflow-0.1.0-windows-setup.exe
4147
retention-days: 7 # Optional: Set artifact retention period
48+
- name: Debug Environment
49+
run: |
50+
echo SUPABASE_URL=$SUPABASE_URL
51+
echo SUPABASE_KEY=$SUPABASE_KEY
52+
env:
53+
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
54+
SUPABASE_KEY: ${{ secrets.SUPABASE_KEY }}

lib/main.dart

Lines changed: 53 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -12,42 +12,63 @@ import 'package:supabase_flutter/supabase_flutter.dart';
1212

1313
Future<void> main() async {
1414
WidgetsFlutterBinding.ensureInitialized();
15+
16+
// Load .env file
1517
await dotenv.load(fileName: '.env');
16-
String supabaseUrl = dotenv.env["SUPABASE_URL"] ?? "Url";
17-
String supabaseApiKey = dotenv.env["SUPABASE_KEY"] ?? "your_api_key";
1818

19-
final instance = await Supabase.initialize(
20-
url: supabaseUrl,
21-
anonKey: supabaseApiKey,
22-
);
19+
// Get environment variables with fallback
20+
String supabaseUrl = dotenv.env['SUPABASE_URL'] ?? 'https://default.supabase.co'; // Fallback URL
21+
String supabaseApiKey = dotenv.env['SUPABASE_KEY'] ?? 'your_api_key';
2322

24-
runApp(MultiProvider(
25-
providers: [
26-
ChangeNotifierProvider<SupabaseService>(
27-
create: (_) => SupabaseService(instance.client)),
28-
ChangeNotifierProxyProvider<SupabaseService, AuthenticationProvider>(
29-
create: (ctx) => AuthenticationProvider(
30-
Provider.of<SupabaseService>(ctx, listen: false)),
31-
update: (context, supabaseService, previousAuth) =>
32-
previousAuth ?? AuthenticationProvider(supabaseService),
33-
),
34-
ChangeNotifierProxyProvider<SupabaseService, FlowmanageProvider>(
35-
create: (context) => FlowmanageProvider(
36-
Provider.of<SupabaseService>(context, listen: false)),
37-
update: (context, supabaseService, previousFlowProvider) =>
38-
previousFlowProvider ?? FlowmanageProvider(supabaseService)),
39-
ChangeNotifierProxyProvider<FlowmanageProvider, WorkspaceProvider>(
40-
create: (context) => WorkspaceProvider(
41-
Provider.of<FlowmanageProvider>(context, listen: false)),
42-
update: (context, flowManage, previousWorkspace) =>
43-
previousWorkspace ?? WorkspaceProvider(flowManage),
23+
// Ensure the URL starts with a scheme (e.g., https://)
24+
if (!supabaseUrl.startsWith('http://') && !supabaseUrl.startsWith('https://')) {
25+
supabaseUrl = 'https://$supabaseUrl';
26+
}
27+
28+
try {
29+
final instance = await Supabase.initialize(
30+
url: supabaseUrl,
31+
anonKey: supabaseApiKey,
32+
debug: true, // Enable debug logs to trace issues
33+
);
34+
35+
print('Supabase initialized with URL: $supabaseUrl');
36+
37+
runApp(MultiProvider(
38+
providers: [
39+
ChangeNotifierProvider<SupabaseService>(
40+
create: (_) => SupabaseService(instance.client)),
41+
ChangeNotifierProxyProvider<SupabaseService, AuthenticationProvider>(
42+
create: (ctx) => AuthenticationProvider(
43+
Provider.of<SupabaseService>(ctx, listen: false)),
44+
update: (context, supabaseService, previousAuth) =>
45+
previousAuth ?? AuthenticationProvider(supabaseService),
46+
),
47+
ChangeNotifierProxyProvider<SupabaseService, FlowmanageProvider>(
48+
create: (context) => FlowmanageProvider(
49+
Provider.of<SupabaseService>(context, listen: false)),
50+
update: (context, supabaseService, previousFlowProvider) =>
51+
previousFlowProvider ?? FlowmanageProvider(supabaseService)),
52+
ChangeNotifierProxyProvider<FlowmanageProvider, WorkspaceProvider>(
53+
create: (context) => WorkspaceProvider(
54+
Provider.of<FlowmanageProvider>(context, listen: false)),
55+
update: (context, flowManage, previousWorkspace) =>
56+
previousWorkspace ?? WorkspaceProvider(flowManage),
57+
),
58+
ChangeNotifierProvider<DashboardProvider>(
59+
create: (_) => DashboardProvider()),
60+
ChangeNotifierProvider<LoadingProvider>(create: (_) => LoadingProvider()),
61+
],
62+
child: MyApp(),
63+
));
64+
} catch (e) {
65+
print('Error initializing Supabase: $e');
66+
runApp(MaterialApp(
67+
home: Scaffold(
68+
body: Center(child: Text('Error: $e')),
4469
),
45-
ChangeNotifierProvider<DashboardProvider>(
46-
create: (_) => DashboardProvider()),
47-
ChangeNotifierProvider<LoadingProvider>(create: (_) => LoadingProvider()),
48-
],
49-
child: MyApp(),
50-
));
70+
));
71+
}
5172
}
5273

5374
class MyApp extends StatefulWidget {
@@ -58,7 +79,6 @@ class MyApp extends StatefulWidget {
5879
}
5980

6081
class _MyAppState extends State<MyApp> {
61-
6282
@override
6383
Widget build(BuildContext context) {
6484
return MaterialApp(

0 commit comments

Comments
 (0)