Deploy from connected image not triggering?

I have my deployment connected to an image in ghcr.io. The first time I deployed, it worked fine; however, I just published a new image a few minutes ago, and Railway hasn't picked it up. Does it just take some time? 12fe90d4-42ca-4704-980b-e16da59696c0
Solution:
youd just need the project token - https://docs.railway.app/guides/cli#tokens and then railway redeploy -y --service <service_id>...
Jump to solution
37 Replies
Percy
Percy2mo ago
Project ID: 12fe90d4-42ca-4704-980b-e16da59696c0
Brody
Brody2mo ago
we unfortunately do not monitor for newly published images, simply because there is no good way to do that, with GitHub repos, GitHub sends a webhook, but that doesn't happen when new images are publishing
tiltowait
tiltowaitOP2mo ago
Oh, that’s a shame. What’s the recommended workflow?
Brody
Brody2mo ago
Well I'd first have to ask, why not simply attach the GitHub repo to the railway service and let railway build and deploy the image?
tiltowait
tiltowaitOP2mo ago
I liked the idea of deploying on tag creation vs a push to a branch
Brody
Brody2mo ago
fair enough i assume you have a gh action to build an image right?
tiltowait
tiltowaitOP2mo ago
Yes
Brody
Brody2mo ago
does this action create an image with a different tag every time it builds an image?
tiltowait
tiltowaitOP2mo ago
Yes, but also updates latest
Brody
Brody2mo ago
would you settle for deploying the service from latest when a new image is published?
tiltowait
tiltowaitOP2mo ago
Tbh that’s what I thought I was doing, or at least attempting
Brody
Brody2mo ago
well if you are okay with that, you could call railway redeploy in an action? in an action that runs after a successful image has been built that is
tiltowait
tiltowaitOP2mo ago
Ah, sure, I can do that Thanks
Solution
Brody
Brody2mo ago
youd just need the project token - https://docs.railway.app/guides/cli#tokens and then railway redeploy -y --service <service_id>
tiltowait
tiltowaitOP2mo ago
Thanks. I’ll look into it!
Brody
Brody2mo ago
let me know if you get stuck!
tiltowait
tiltowaitOP2mo ago
Would this be correct?
deploy:
needs: build
runs-on: ubuntu-latest

steps:
- name: Use Node 22
uses: action/setup-node@v4
with:
node-version: 22.x

- name: Install Railway
run: npm i -g @railway/cli

- name: Deploy
run: railway redeploy -y --service <service_id>
env:
RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }}
deploy:
needs: build
runs-on: ubuntu-latest

steps:
- name: Use Node 22
uses: action/setup-node@v4
with:
node-version: 22.x

- name: Install Railway
run: npm i -g @railway/cli

- name: Deploy
run: railway redeploy -y --service <service_id>
env:
RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }}
Brody
Brody2mo ago
i honestly dont know the syntax for github actions off the top of my head, but id use the docker image for the cli and an environment variable for <service_id>
tiltowait
tiltowaitOP2mo ago
Okay, wasn't sure if the service ID should be secret or not
Brody
Brody2mo ago
nope, its just a uuid
tiltowait
tiltowaitOP2mo ago
the docker image for the cli
Do you mean my docker image, or is there a Railway image?
tiltowait
tiltowaitOP2mo ago
deploy:
needs: build
runs-on: ubuntu-latest
container: ghcr.io/railwayapp/cli:latest
env:
SVC_ID: <blah>
RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }}

steps:
- name: Deploy new image
run: railway redeploy -y --service ${{ env.SVC_ID }}
deploy:
needs: build
runs-on: ubuntu-latest
container: ghcr.io/railwayapp/cli:latest
env:
SVC_ID: <blah>
RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }}

steps:
- name: Deploy new image
run: railway redeploy -y --service ${{ env.SVC_ID }}
Brody
Brody2mo ago
do you still need runs-on if you are providing the image? I genuinely don't know, and I'd still use a GitHub secret for the service id, while it's not sensitive, I'd image updating the service id via there GitHub UI is going to be easier / more efficient than editing the action file
tiltowait
tiltowaitOP2mo ago
the example had the runs-on
No description
Brody
Brody2mo ago
fair, a team member didn't write that, so I'm not sure if it's correct, would you mind fact checking that?
tiltowait
tiltowaitOP2mo ago
Sure. Will probably be a couple of days before my next deployment 👍
Brody
Brody2mo ago
you can still trigger that action via a button though right?
tiltowait
tiltowaitOP2mo ago
Yeah, this is just the job. I cut out the rest of the workflow, which triggers on tag creation
Brody
Brody2mo ago
then the example on our repo is likely correct
tiltowait
tiltowaitOP2mo ago
Cool, thanks for the help. I'll let you know if it works (In case it helps anyone else trying the same thing)
Brody
Brody2mo ago
sounds good!
tiltowait
tiltowaitOP4w ago
@Brody the redeployment triggers work 🙂 (Though they didn't behave as I wanted this time, because my last deployment was via railway up, not Docker, so it didn't actually get the new code. I addressed that, so hopefully it will work correctly moving forward)
No description
Brody
Brody4w ago
yeah it's only going to deploy whatever the most recent deployment is, of you wanna redeploy from source you will need to call the API manually
tiltowait
tiltowaitOP4w ago
Yep, makes sense It took a moment to figure out how to redeploy via image. I thought unlinking then re-linking would do it, but I had to click redeploy from the original docker deployment
Brody
Brody4w ago
well I'm glad you've solved this
Want results from more Discord servers?
Add your server