Bud deploy variável de ambiente
pakari
HOBBYOP

a year ago

I'm changing an environment variable in my github service, I set it to deploy and it's not happening. Everything is fine, history and everything... but the deployment isn't happening... I had to do a redeploy for it to work.

Solved$10 Bounty

3 Replies

melivoracapensis
FREE

a year ago

Changing environment variables in the dashboard usually does NOT automatically trigger a redeploy or build.

(Except in some rare, advanced configurations)

After changing an environment variable, always manually trigger a redeploy (or restart) if you want the new value to be picked up by your app.

On Railway:

Go to your service → click “Redeploy” (or “Restart” if it’s an always-on service).

Or, you can push a dummy commit to GitHub (like updating a comment) if you want to automate via code.

If you want a deploy to trigger whenever env variables are changed, you’ll need to:

Use Railway’s API (if available) to script a redeploy after env changes. Or, use GitHub Actions or similar to trigger a deploy command.

But for almost all normal cases, manually redeploying after changing env vars is the standard workflow.

1.If You Store Env Vars in GitHub.

Secrets needed in GitHub repo:

RAILWAY_API_TOKEN

RAILWAY_PROJECT_ID

RAILWAY_SERVICE_ID

.github/workflows/redeploy-on-env-change.yml:

name: Redeploy on Env Change

on:
  push:
    paths:
      - '.env'
      - 'your/env/dir/*.env'  # Add more paths if you have multiple env files

jobs:
  redeploy:
    runs-on: ubuntu-latest
    steps:
      - name: Trigger Railway Deploy via API
        run: |
          curl -X POST https://backboard.railway.app/graphql/v2 \
            -H "Authorization: Bearer ${{ secrets.RAILWAY_API_TOKEN }}" \
            -H "Content-Type: application/json" \
            -d '{
              "query": "mutation DeployService($input: DeployServiceInput!) { deployService(input: $input) { id status } }",
              "variables": {
                "input": {
                  "projectId": "'"${{ secrets.RAILWAY_PROJECT_ID }}"'",
                  "serviceId": "'"${{ secrets.RAILWAY_SERVICE_ID }}"'"
                }
              }
            }'

pakari
HOBBYOP

a year ago

It wasn't like that before. It was automatic.


pakari

It wasn't like that before. It was automatic.

a year ago

Hey, Railway will automatically redeploy your service if it detects changes for any environment/service variable. What you have experienced may be related to an incident regarding builds.


Status changed to Solved uxuz 12 months ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...