66 pull_request :
77 branches : [ main ]
88 workflow_dispatch :
9+ inputs :
10+ deploy_to_railway :
11+ description : ' Deploy to Railway (only for testing)'
12+ required : false
13+ default : false
14+ type : boolean
915
1016# Add permissions for CodeQL/SARIF upload
1117permissions :
@@ -311,7 +317,7 @@ jobs:
311317 name : 🚀 Railway Production Deployment
312318 runs-on : ubuntu-latest
313319 needs : [pre-deployment]
314- if : github.ref == 'refs/heads/main' && github.event_name == 'push'
320+ if : ( github.ref == 'refs/heads/main' && github.event_name == 'push') || github.event.inputs.deploy_to_railway == 'true '
315321 environment :
316322 name : production
317323 url : ${{ steps.deploy.outputs.url }}
@@ -326,14 +332,24 @@ jobs:
326332 RAILWAY_TOKEN : ${{ secrets.RAILWAY_TOKEN }}
327333 run : |
328334 echo "Installing Railway CLI..."
329- # Download Railway CLI with explicit version
330- curl -L -o railway "https://github.com/railwayapp/cli/releases/latest/download/railway-linux-amd64"
331- chmod +x railway
332- sudo mv railway /usr/local/bin/railway
335+ # Use specific version that is known to work
336+ RAILWAY_VERSION="v3.17.1"
337+ curl -L -o railway "https://github.com/railwayapp/cli/releases/download/${RAILWAY_VERSION}/railway-linux-amd64" || {
338+ echo "Failed to download specific version, trying alternative..."
339+ # Alternative: Use npm installation
340+ npm install -g @railway/cli
341+ ln -sf $(npm root -g)/@railway/cli/bin/railway /usr/local/bin/railway
342+ }
343+
344+ # Make executable if downloaded directly
345+ if [ -f "railway" ]; then
346+ chmod +x railway
347+ sudo mv railway /usr/local/bin/railway
348+ fi
333349
334350 echo "Verifying Railway CLI installation..."
335351 which railway
336- railway --version
352+ railway --version || railway version
337353
338354 echo "Checking Railway authentication..."
339355 if [ -z "$RAILWAY_TOKEN" ]; then
@@ -342,18 +358,12 @@ jobs:
342358 fi
343359 echo "✅ RAILWAY_TOKEN is configured"
344360
345- echo "Linking to existing Railway project..."
346- # Create railway.json to link to existing project if it doesn't exist
347- if [ ! -f "railway.json" ]; then
348- echo "Creating Railway configuration..."
349- # This will be handled by railway up command
350- fi
351-
352361 echo "Deploying to Railway..."
353- railway up --detach --service neurobank-fastapi || {
354- echo "❌ Railway deployment failed, retrying with different approach..."
355- sleep 10
356- # Try without service flag
362+ # Use railway up without specific service first
363+ railway up --detach || {
364+ echo "❌ Basic deployment failed, trying with project linking..."
365+ # Try to link to existing project if needed
366+ railway login --token "$RAILWAY_TOKEN" 2>/dev/null || true
357367 railway up --detach
358368 }
359369
0 commit comments