9 months ago
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
0 Replies
9 months 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
9 months 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?
9 months ago
fair enough
9 months ago
i assume you have a gh action to build an image right?
9 months ago
does this action create an image with a different tag every time it builds an image?
9 months ago
would you settle for deploying the service from latest when a new image is published?
9 months ago
well if you are okay with that, you could call railway redeploy
in an action?
9 months ago
in an action that runs after a successful image has been built that is
9 months ago
youd just need the project token -
and then railway redeploy -y --service
9 months ago
let me know if you get stuck!
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
env:
RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }}
9 months 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 ``
9 months ago
nope, its just a uuid
the docker image for the cli
Do you mean my docker image, or is there a Railway image?
9 months ago
this one -
deploy:
needs: build
runs-on: ubuntu-latest
container: ghcr.io/railwayapp/cli:latest
env:
SVC_ID:
RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }}
steps:
- name: Deploy new image
run: railway redeploy -y --service ${{ env.SVC_ID }}
9 months 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
9 months ago
fair, a team member didn't write that, so I'm not sure if it's correct, would you mind fact checking that?
The official GH docs show runs-on with container: https://docs.github.com/en/actions/writing-workflows/choosing-where-your-workflow-runs/running-jobs-in-a-container
9 months ago
you can still trigger that action via a button though right?
Yeah, this is just the job. I cut out the rest of the workflow, which triggers on tag creation
9 months ago
then the example on our repo is likely correct
9 months ago
sounds good!
@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)
9 months 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
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
9 months ago
well I'm glad you've solved this