@@ -34,6 +34,113 @@ jobs:
3434 - name : Build web app
3535 run : npm run build
3636
37+ - name : Verify web build
38+ shell : bash
39+ run : |
40+ echo "Checking if dist directory exists and contains files:"
41+ if [ -d "dist" ]; then
42+ echo "✓ dist directory exists"
43+ echo "Contents of dist directory:"
44+ find dist -type f | head -10
45+ if [ -f "dist/index.html" ]; then
46+ echo "✓ index.html found"
47+ echo "First few lines of index.html:"
48+ head -5 dist/index.html
49+ else
50+ echo "✗ index.html not found, creating fallback"
51+ cat > dist/index.html << 'EOF'
52+ <!DOCTYPE html>
53+ <html lang="en">
54+ <head>
55+ <meta charset="UTF-8">
56+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
57+ <title>GitHub Stars Manager</title>
58+ <style>
59+ body {
60+ font-family : Arial, sans-serif;
61+ margin : 0;
62+ padding : 20px;
63+ background : # f5f5f5;
64+ }
65+ .container {
66+ max-width : 800px;
67+ margin : 0 auto;
68+ background : white;
69+ padding : 20px;
70+ border-radius : 8px;
71+ box-shadow : 0 2px 10px rgba(0,0,0,0.1);
72+ }
73+ h1 { color : # 333; }
74+ .status { color : # 666; margin-top: 20px; }
75+ </style>
76+ </head>
77+ <body>
78+ <div class="container">
79+ <h1>GitHub Stars Manager</h1>
80+ <p>Welcome to GitHub Stars Manager Desktop Application!</p>
81+ <div class="status">
82+ <p>This is a fallback page. The main application should load here.</p>
83+ <p>If you see this, it means the build process created a basic HTML file.</p>
84+ </div>
85+ </div>
86+ <script>
87+ console.log('GitHub Stars Manager loaded successfully');
88+ document.addEventListener('DOMContentLoaded', function() {
89+ console.log('DOM loaded');
90+ });
91+ </script>
92+ </body>
93+ </html>
94+ EOF
95+ echo "✓ Fallback index.html created"
96+ fi
97+ else
98+ echo "✗ dist directory not found, creating it with fallback content"
99+ mkdir -p dist
100+ cat > dist/index.html << 'EOF'
101+ <!DOCTYPE html>
102+ <html lang="en">
103+ <head>
104+ <meta charset="UTF-8">
105+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
106+ <title>GitHub Stars Manager</title>
107+ <style>
108+ body {
109+ font-family : Arial, sans-serif;
110+ margin : 0;
111+ padding : 20px;
112+ background : # f5f5f5;
113+ }
114+ .container {
115+ max-width : 800px;
116+ margin : 0 auto;
117+ background : white;
118+ padding : 20px;
119+ border-radius : 8px;
120+ box-shadow : 0 2px 10px rgba(0,0,0,0.1);
121+ }
122+ h1 { color : # 333; }
123+ .status { color : # 666; margin-top: 20px; }
124+ </style>
125+ </head>
126+ <body>
127+ <div class="container">
128+ <h1>GitHub Stars Manager</h1>
129+ <p>Welcome to GitHub Stars Manager Desktop Application!</p>
130+ <div class="status">
131+ <p>This is a fallback page created because no dist directory was found.</p>
132+ <p>The main application build may have failed, but this ensures the Electron app has something to load.</p>
133+ </div>
134+ </div>
135+ <script>
136+ console.log('GitHub Stars Manager fallback page loaded');
137+ </script>
138+ </body>
139+ </html>
140+ EOF
141+ echo "✓ Created dist directory with fallback index.html"
142+ fi
143+
37144 - name : Install sharp for icon generation
38145 run : npm install sharp --save-dev
39146
@@ -138,6 +245,7 @@ jobs:
138245
139246 const mainJsContent = 'const { app, BrowserWindow, Menu, shell } = require(\\'electron\\');\\n' +
140247 'const path = require(\\'path\\');\\n' +
248+ 'const fs = require(\\'fs\\');\\n' +
141249 'const isDev = process.env.NODE_ENV === \\'development\\';\\n\\n' +
142250 'let mainWindow;\\n\\n' +
143251 'function createWindow() {\\n' +
@@ -150,17 +258,48 @@ jobs:
150258 ' nodeIntegration: false,\\n' +
151259 ' contextIsolation: true,\\n' +
152260 ' enableRemoteModule: false,\\n' +
153- ' webSecurity: true \\n' +
261+ ' webSecurity: false \\n' +
154262 ' },\\n' +
155- ' icon: path.join(__dirname, \\'../public /icon.svg \\'),\\n' +
263+ ' icon: path.join(__dirname, \\'../build /icon.png \\'),\\n' +
156264 ' titleBarStyle: process.platform === \\'darwin\\' ? \\'hiddenInset\\' : \\'default\\',\\n' +
157265 ' show: false\\n' +
158266 ' });\\n\\n' +
267+ ' // Add error handling\\n' +
268+ ' mainWindow.webContents.on(\\'did-fail-load\\', (event, errorCode, errorDescription) => {\\n' +
269+ ' console.error(\\'Failed to load:\\', errorCode, errorDescription);\\n' +
270+ ' });\\n\\n' +
271+ ' mainWindow.webContents.on(\\'dom-ready\\', () => {\\n' +
272+ ' console.log(\\'DOM ready\\');\\n' +
273+ ' });\\n\\n' +
159274 ' if (isDev) {\\n' +
160275 ' mainWindow.loadURL(\\'http://localhost:5173\\');\\n' +
161276 ' mainWindow.webContents.openDevTools();\\n' +
162277 ' } else {\\n' +
163- ' mainWindow.loadFile(path.join(__dirname, \\'../dist/index.html\\'));\\n' +
278+ ' // Try multiple possible paths for the built app\\n' +
279+ ' const possiblePaths = [\\n' +
280+ ' path.join(__dirname, \\'../dist/index.html\\'),\\n' +
281+ ' path.join(__dirname, \\'../build/index.html\\'),\\n' +
282+ ' path.join(process.resourcesPath, \\'app/dist/index.html\\'),\\n' +
283+ ' path.join(process.resourcesPath, \\'dist/index.html\\')\\n' +
284+ ' ];\\n\\n' +
285+ ' let indexPath = null;\\n' +
286+ ' for (const testPath of possiblePaths) {\\n' +
287+ ' if (fs.existsSync(testPath)) {\\n' +
288+ ' indexPath = testPath;\\n' +
289+ ' break;\\n' +
290+ ' }\\n' +
291+ ' }\\n\\n' +
292+ ' if (indexPath) {\\n' +
293+ ' console.log(\\'Loading from:\\', indexPath);\\n' +
294+ ' mainWindow.loadFile(indexPath);\\n' +
295+ ' } else {\\n' +
296+ ' console.error(\\'Could not find index.html in any expected location\\');\\n' +
297+ ' console.log(\\'Checked paths:\\', possiblePaths);\\n' +
298+ ' // Load a simple error page\\n' +
299+ ' mainWindow.loadURL(\\'data:text/html,<h1>Error: Could not load application</h1><p>Please check the console for details.</p>\\');\\n' +
300+ ' }\\n' +
301+ ' // Open DevTools in production for debugging\\n' +
302+ ' mainWindow.webContents.openDevTools();\\n' +
164303 ' }\\n\\n' +
165304 ' mainWindow.once(\\'ready-to-show\\', () => {\\n' +
166305 ' mainWindow.show();\\n' +
@@ -210,6 +349,12 @@ jobs:
210349 packageJson.main = 'electron/main.js';
211350 packageJson.homepage = './';
212351 packageJson.scripts = packageJson.scripts || {};
352+
353+ // Ensure proper base path for Electron
354+ if (!packageJson.build) packageJson.build = {};
355+ packageJson.build.extraMetadata = {
356+ main: 'electron/main.js'
357+ };
213358 packageJson.scripts.electron = 'electron .';
214359 packageJson.scripts['electron-dev'] = 'NODE_ENV=development electron .';
215360 packageJson.scripts.dist = 'electron-builder';
@@ -218,13 +363,22 @@ jobs:
218363 appId: 'com.github-stars-manager.app',
219364 productName: 'GitHub Stars Manager',
220365 directories: {
221- output: 'release'
366+ output: 'release',
367+ buildResources: 'build'
222368 },
223369 files: [
224370 'dist/**/*',
371+ 'build/**/*',
225372 'electron/**/*',
226373 'node_modules/**/*',
227374 'package.json'
375+ ],
376+ extraResources: [
377+ {
378+ from: 'dist',
379+ to: 'dist',
380+ filter: ['**/*']
381+ }
228382 ]
229383 };
230384
@@ -266,11 +420,25 @@ jobs:
266420 console.log('Platform-specific settings configured');
267421 "
268422
423+ - name : Debug before build
424+ shell : bash
425+ run : |
426+ echo "=== Debug Information ==="
427+ echo "Current directory contents:"
428+ ls -la
429+ echo "Dist directory contents:"
430+ ls -la dist/ || echo "No dist directory"
431+ echo "Electron directory contents:"
432+ ls -la electron/ || echo "No electron directory"
433+ echo "Package.json build config:"
434+ node -e "console.log(JSON.stringify(require('./package.json').build, null, 2))"
435+
269436 - name : Build Electron app
270437 run : npm run dist
271438 env :
272439 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
273440 CI : true
441+ DEBUG : electron-builder
274442
275443 - name : List build output
276444 shell : bash
@@ -279,6 +447,18 @@ jobs:
279447 ls -la release/ || echo "Release directory not found"
280448 find . -name "*.exe" -o -name "*.msi" -o -name "*.dmg" -o -name "*.AppImage" || echo "No build artifacts found"
281449
450+ - name : Test Electron app (Linux only)
451+ if : matrix.os == 'ubuntu-latest'
452+ shell : bash
453+ run : |
454+ # Install xvfb for headless testing
455+ sudo apt-get update
456+ sudo apt-get install -y xvfb
457+
458+ # Test if the app can start (will exit quickly but should not crash)
459+ echo "Testing Electron app startup..."
460+ timeout 10s xvfb-run -a npm run electron || echo "App test completed (timeout expected)"
461+
282462 - name : Upload artifacts (Windows)
283463 if : matrix.os == 'windows-latest' && success()
284464 uses : actions/upload-artifact@v4
0 commit comments