RailwayDocs
Back to Guides

GitHub Actions PR Environment

github-actionsci-cdautomationenvironments

Github Actions come with a pretty neat set of features to automate your workflows. This post talks about using Github Actions alongside the Railway CLI to create specific environments for any PR that is created, alongside closing it whenever it is closed/merged.

This can be useful if you need to create a branch on a Neon database, allowing you to automatically inject the correct database url.

The action

Make a new file in your repository called .github/workflows/railway-pr-envs.yml and add the following -

Note: If you are using a project in a workspace, you need to ensure that the token specified is scoped to your account, not just the workspace.

This can very easily be modified to run commands in order to find variables and values, and can simply be passed as flags to the railway environment create command.

Conclusion

We hope this tutorial has been helpful and that you'll find it useful for your own projects. If you have any questions or feedback, please feel free to reach out to us on Discord, Slack or the Central Station. Happy coding!