9 months ago
I am trying to deploy a project that used to be connected to github directly as a container image deployment, but there is no way for me to programmatically trigger a deploy from my GH CI environment using the pre-built image my CI is creating using the same :latest tag. (I need GH to build it because the --ssh
flag is not supported by railway)
I am trying to do so via the railway cli app in my CI, does not seem to be a way to do so
ⓘ Deployment information is only viewable by project members and Railway employees.
10 Replies
9 months ago
seems like railway redeploy -y
does the trick maybe
9 months ago
Nope. cannot execute railway link
without railway login,
cannot execute railway login
in non-interctive terminal
9 months ago
Can you try to set a project token environment variable in your action?
9 months ago
here is my github action job that does the deployment (on main
branch, after my docker job has built and deployed the private image to ghcr.io
):
env:
REGISTRY: ghcr.io
RAILWAY_ENVIRONMENT: staging
RAILWAY_PROJECT_ID: <project-id>
RAILWAY_SERVICE_ID: <service-id>
...
jobs:
... # build job + others
deploy-app:
needs: [build-app, functional-test, fuzz-test, migrations-test]
if: github.event_name != 'pull_request'
runs-on: ubuntu-latest
container: ghcr.io/railwayapp/cli:latest
steps:
- run: |
railway login # <-- I added this because `railway link` yells about not being logged in
railway link \
--project ${{ env.RAILWAY_PROJECT_ID }} \
--service ${{ env.RAILWAY_SERVICE_ID }} \
--environment ${{ env.RAILWAY_ENVIRONMENT }}
railway redeploy -y # Trigger last deployment, which is using :latest tag anyways
env:
RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN_STAGING }}
9 months ago
At first, I didn't have railway login
in there, and I got this:
Run railway link \
Unauthorized. Please login with `railway login`
Error: Process completed with exit code 1.
Then I added it:
Run railway login
railway login
railway link \
--project <project-id> \
--service <service-id> \
--environment staging
railway redeploy -y # Trigger last deployment, which is using :latest tag anyways
shell: sh -e {0}
env:
REGISTRY: ghcr.io
RAILWAY_ENVIRONMENT: staging
RAILWAY_PROJECT_ID: ***
RAILWAY_SERVICE_ID: ***
RAILWAY_TOKEN: ***
Cannot login in non-interactive mode
Error: Process completed with exit code 1.
9 months ago
You shouldn't need to run railway login
in a GH action, that is what the token is designed to be used for.
Can you please have a look at the link I sent above?
9 months ago
If you notice in my example snippet, RAILWAY_TOKEN
is in env
when the command is run, I only put railway login
because railway link
didn't work
9 months ago
My apologies, I had overlooked that because I saw that you were still using railway login
Now that you have a token set, remove the login
and link
commands, and call redeploy with a --service
flag.
9 months ago
Okay, thank you that worked. I think I had tried that without the --service
flag at some point and it didn't work, and didn't match the local CLI experience (which had led me down the path of using railway link
)