Configuring GitHub repos to run on Repl.it and contributing back
You might have noticed that it's now possible to import your GitHub repos into repls. If you haven't yet, consider connecting your GitHub account to repl.it to make it easier to import and contribute back.
In this guide I'm going to show you how to configuring a repo to run on repl.it and how you can contribute back a neat "run on repl.it" button to the repo. It looks like this:
I'm going to use this repo (https://github.com/plibither8/2048.cpp) as an example. (It's an implementation of 2048 in C++ that works in the terminal!)
First let's import the repo to repl.it. Click "import repo" from the header.
Then add in the repo url:
Click "create from GitHub" and after the repo clones you'll see a configuration pane to figure out the language and how to run the repo.
Now, you have to try to figure out the run command from the repo. Typically, you'd want to read the instructions in the readme or play with it in the shell to figure out how to best run it. In this case I figured out that:
- The language is cpp (from the name duh)
- From the readme I figured out that the run command should be
cd build && cmake ../ && cmake --build . && ./2048
Click "done" and then you'll see two things:
- A .replit file: This is where the configuration gets saved
- The config pane gets replaced with instructions on how to contribute the run badge and configuration back to the repo
Before we get to contribute back let's make sure it actually runs:
Sweet! Now follow the steps in the pull request pane which should give you code to paste in the readme:
Preview the readme and make sure the "run on repl.it" button renders correctly:
Now simply click on "prepare pull request" which will take you to GitHub where you can fill in the rest of the details. For this repo, I already sent a pull request. Check it out: https://github.com/plibither8/2048.cpp/pull/117
I'm excited to see more Repl.it badges all over GitHub so that all repos can be easily run. Please help people get their repos work on Repl.it and in the process contribute to open source!