We will deploy the discord bot we created in our previous article. Railway gives a seamless deployment experience.
Visit their website 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 through GitHub.
Now in the dashboard click on New Project.
And in the pop-up select Deploy from GitHub repo in our case. Our Discord bot project is a public GitHub project - GitHubDiscordBot.
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.
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.
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.
When you click on either of those options, a new project will be created in Railway with your chosen GitHub project.
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.
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
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.
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.