Deploying with a GitHub Action
I'm looking for some pointers on how to deploy our app via GitHub actions. Specifically I am having trouble specifying the environment when I link the project.
I have tried running
This works and links to that environment. However, when I follow it up with
it prompts me for the environment to deploy to. Is there a way to provide an environment flat to the link so that it knows which environment to deploy to with running ?
Any help on this would be appreciated. What I am ultimately trying to do it deploy to a specific service, within a specifc environment from a Github action.
57 Replies
Project ID:
d36cedc3-d1a4-453b-9e36-45d7299cabfd
d36cedc3-d1a4-453b-9e36-45d7299cabfd
provide both the
--environment
and --service
flags directly to railway up
so you can skip railway link
and railway environment
Is the service arg the uuid of the service, or the name itself?
i think both work, but im not exactly sure on that
Ok, going to give that a whirl! Do i need to adjust the custom build command or will it bypass it when
up
is used?is this a build command you have set in the service settings?
I had it set in the Railway dashboard from when I was using the github integration
and hte build was happening on railway, now the build is happening in the github action and i just want to pass over the directory
build is still happening on railway, your just using the cli to ship your code to railway in a tarball instead of having railway pull your repo
Ah ok - but the contents of the current directory that im in with calling railway up is what itll have access to when running its build?
that sounds correct, that what
railway up
would bundle up and sent to railwayOk I think Im set for now, appreciate the help!
no prob!
speaking of that, maybe it would be a good idea to create a railway action?
go for it
u serious?
what I mean is I can totally do that but is it actually needed
you know better than I do
if you need it and it's something you want, then build it
I use gitlab 💀
well that's a whole other separate issue
@Brody -
- Does this in anyway look at the .gitignore when it runs the build command in Railway to decide whether to include certain files?
-Is there a way to pry into the deployment to inspect the file contents?
-- Figured this out (just read the docs 😆 ) - and the file is in fact there, so not quite sure why its saying it cant find it.
- The problem I am running into is that I am generating the types for the project in Github actions, and passing those types in the newly created files along with the
-
railway up
command. When the project is ran in Railway, its not finding those files. Those type files are included in the .gitignore if that makes a difference
I just cache the CLI in Github, makes it speedyrailway up
does indeed ignore patterns specified in the .gitignoreThe files are there when I jump into the box. They are fresh every build no?
jump into the box?
open up a shell for the service
railway does not provide a shell or ssh for the container, if you are referring to
railway shell
that is a local shell, but with the linked service variables now available locallyAh I see - how can I tell what the directory looks like for the service?
it would look like your project minus files and folders that are in the .gitignore, but whats been uploaded gets placed in an /app directory at the root of the container
if you have the types in your .gitignore file
railway up
wont upload themHmm ok - gotta figure out a way around that for my usage then.
have railway's build generate the types?
I think so..
why not? (genuine question)
Right now just extra config to ensure the type generation scripts can all work within the railway ecosystem (env vars n such) - was aiming to have the dx be all of that was handled in github, and railway just hosted the service
i think you should let railway do that stuff too, work with railway
and to be fair I already have to manage the env vars within railway for all of the thing swithin the code the references those values anyways, will just need to add whats needed to generate the types
question, are you building with a dockerfile?
I am not
Can I reference environment variables inline in the build commands?
eg in Github ive got
that doesnt look like a build command, but you can add those env vars to the service and then referance them with the linux
$ENV_VAR
syntax in a custom phase inside your nixpacks.toml file, like so
where would that phases command by referenced in the build config for the project?
what do you mean exactly by build config? nixpacks.toml is a build config
I am setting the build command in the railway ui for example, are the things in the nixpacks.toml executed before that?
the command you provided really doesn’t look like a build command, so you ideally wouldn't be setting that kind of command as the build command.
but the phases can run at any point during the build with that
dependsOn
keywordIts just one of the commands im running as part of the type generation
a build command would more so be something like
yarn workspace backend build
Hm, trying to run the command in the nixpacks.toml
Am I able to see that error on my end? Its not the build logs?
yeah i copied it from the log you sent me
Ah 🤦♂️ - I see it just not where I expected it
it never is
We're in business, that approach is working!
awesome!
Just wanted to add a note that it would be cool if there was a way (and if there is I couldnt find it), to create environments on the fly with the CLI. The github integration was neat as it synced the PR to its own environment. Was messing with trying to do that without the github integration and wasnt able to get anywhere.
that's actually asked quite frequently
cc @Melissa
literally just yesterday we were talking about adding the ability to create envs in the CLI. i'll create a ticket, i think Ray is going to start giving the CLI some attention soon
Everytime I've come into this Discord for the past year or so you all are always helpful. Much appreciated! Is the github integration open source from you all that I can see what all it was doing?
it's not, that would all be internal to railway
@drewbie I would highly suggest https://github.com/github/branch-deploy (full disclosure I am the creator)
There are examples on how to use it with railway here: https://github.com/github/branch-deploy/blob/main/docs/examples.md#railway
Also, here is an article I wrote about what the "branch deploy model" is and why you should use it -> https://blog.birki.io/posts/branch-deploy/