Railway Deploy
yaml
1jobs:
2 deploy:
3 runs-on: ubuntu-latest
4 needs: test
5 if: github.ref == 'refs/heads/main'
6
7 steps:
8 - uses: actions/checkout@v4
9
10 - name: Install Railway CLI
11 run: npm install -g @railway/cli
12
13 - name: Deploy to Railway
14 run: railway up
15 env:
16 RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }}With Docker
yaml
1- name: Deploy Docker to Railway
2 run: railway up --service myapp
3 env:
4 RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }}Environment-Specific Deploy
yaml
1deploy-staging:
2 runs-on: ubuntu-latest
3 needs: test
4 if: github.ref == 'refs/heads/develop'
5 environment: staging
6 steps:
7 - uses: actions/checkout@v4
8 - run: railway up --environment staging
9 env:
10 RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN_STAGING }}
11
12deploy-production:
13 runs-on: ubuntu-latest
14 needs: test
15 if: github.ref == 'refs/heads/main'
16 environment: production
17 steps:
18 - uses: actions/checkout@v4
19 - run: railway up --environment production
20 env:
21 RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN_PROD }}Post-Deploy Tasks
yaml
1- name: Run migrations
2 run: railway run rails db:migrate
3 env:
4 RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }}