Automatically deploy from GitHub to Replit, lightning fast ⚡️
repl.deploy
is split into
Authorize repl.deploy to get events from GitHub
Make sure you have a main
branch on your origin
remote
Add replit-deploy.json
to your git repository with a single endpoint
key,
which is the address of your repl + /refresh
. E.g.
{
"endpoint": "https://my-amazing-application.my-username.repl.co/refresh"
}
Clone your git repository to your repl
Download repl.deploy
to the root of your repl -- Open the shell, and run
curl -sL https://repl-deploy.vercel.app/ -o repl.deploy
chmod +x ./repl.deploy
WARNING: Proceeding will overwrite any local changes and reset from your GitHub repo. Commit AND push any local changes BEFORE running repl.deploy
For repls that do not use an HTTP server in their code (See example)
.replit
file in the root of your repl and change
run=
to run ./repl.deploy --standalone <command to run your code here>
. E.g.run="./repl.deploy --standalone node index.js"
For repls that use an HTTP server in their code (See example)
.replit
file in the root of your repl and change
run=
to run ./repl.deploy <command to run your code here>
. E.g.run="./repl.deploy node index.js"
/refresh
endpoint, and log a line in the following format to
stdout
when a request is recieved: repl.deploy<insert json body here (don't include the angle brackets)><insert "Signature" header here (don't include the angle brackets)>
. E.g.repl.deploy{"timestamp":1615896087141,"endpoint":"https://8c051d0fbc4b.ngrok.io/refresh"}ostjM6/jGmHbRWcHazxKWSPmvgvoIryI9XxLgNKgxPCKRW==
stdin
. E.g.{"status":"403","body":"Invalid Signature"}
simply respond with the given status and body (see example)
stdout
)repl.deploy-success
Click Run
once. Make sure your repl is set to always-on or has a pinging
service set up (otherwise, the daemon will be
stopped by repl once you close your browser tab)
That's it! Repl.it should automatically pull changes from GitHub the next time you commit
When you commit, GitHub sends an event to a hosted instance of the
repl.deploy
server
A payload consisting of both the endpoint and the current time is prepared and signed with an RSA private key
The daemon running on the repl recieves the payload, and
If the request is valid, the daemon
git fetch --all
and then git reset --hard origin/main
Q: What does run="./repl.deploy --standalone node index.js"
do?
A: It makes the Replit Run
button run the daemon instead of executing the
program directly, which then executes/re-executes the program on git push
Q: Does repl.deploy need to be downloaded every time the program is run?
A: No, repl.deploy only needs to be downloaded once per repl
Q: What's https://repl-deploy.vercel.app/
?
A: A hosted version of
get-release-url, which saves
you the time of manually finding the latest release and linking it.