Deploying a Nodejs project to Railway
Tags: discord, deploy, railwayapp, hosting
Published: 2023-09-28 07:50:40

We will deploy the [discord bot](https://vic0de.com/nodejs-discord-bot-create-github-issues-with-slash-commands) we created in our previous article. Railway gives a seamless deployment experience.

Visit their [website](https://railway.app/?referralCode=I5697z) and click login, and in the pop-up, choose GitHub or Email sign-in option. If you choose GitHub, in the next step click on the button that says Authorize Railway App.

And done, you have now created an account with [Railway](https://railway.app/?referralCode=I5697z) through GitHub.

Now in the dashboard click on New Project.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1695883174720/fc651faf-3288-40bf-b3cd-48453cca314e.png align="center")

And in the pop-up select Deploy from GitHub repo in our case. Our Discord bot project is a public GitHub project - [GitHubDiscordBot](https://github.com/VishnuDileesh/GithubDiscordBot).

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1695883677257/c5aef63e-0ba3-4bc8-a6d7-18e5a8fe86d1.png align="center")

In the next step click on Configure GitHub App, and a pop-up will open with GitHub asking you to select where to install the Railway App. Select your account.

Next, choose the permissions and access controls. Then for the last step click on the green button that says Install & Authorize.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1695883791132/47f4c11d-79ce-4847-8669-c2cd02001a45.png align="center")

Now you will be back in your dashboard. Give a refresh and if you click on the New Project again and choose Deploy from GitHub, it will load repositories from your GitHub account.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1695883978076/693a0223-0484-4f68-97ff-df06d0854b75.png align="center")

Select the project you want to deploy. And in the next step, you can deploy straight away or choose to add the needed environment variables.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1695884067088/81ed480d-4fe0-423c-aac0-c3f497736751.png align="center")

When you click on either of those options, a new project will be created in Railway with your chosen GitHub project.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1695884135583/404d3af3-2850-4a45-b33e-37e09cd7da33.png align="center")

Here you can add your environment variables. In my case, I will add the variables listed in the .env\_example file in the project GitHub folder.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1695884250409/3834a6a3-b9af-458c-a668-bb3c57b99275.png align="center")

In the Settings page, you can choose the branch you wish to deploy. And other details like what should the start command be.

In my case, I added the start command as

> npm run start

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1695884457065/a013df00-3525-47d3-9acc-89358fe76241.png align="center")

Each time you make changes here in the project dashboard, like adding or removing an environment variable, or pushing a new update to the project GitHub repo, Railway will re-build the project and will deploy again.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1695884771804/ba84e614-b10a-467f-8551-ea04ba1c9601.png align="center")

In the Deployments, you can see your past deployment and the one running now. If you click on the View Logs button you can see different logs like Build Logs and Deploy Logs, and other details.

In the settings, you can also choose the deployment region, generate a domain, or add a custom domain, and other major changes can be made.

And that's it, you now have your project running live on [Railway](https://railway.app/?referralCode=I5697z).

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1695885280016/47743653-3527-4db9-89d8-4eac784aa88a.png align="center")