Deploy to Glitch with a single git push.
- Fork the Git Glitched GitHub repo.
- Copy the URL of your forked repo. You'll need it in a second.
- Create a new Glitch project based on your forked repo:
- In the top left corner of Glitch, click your project name.
- Click New Project ✨.
- Click Clone from Git Repo.
- When Glitch asks what Git repo you want to clone from, enter the URL of your forked repo. (That's the one you copied a second ago.)
- In your newly created Glitch project, go to the .env.example file and follow the directions there for setting your
SECRETenvironment variable. - Open the Glitch console. As I'm writing this, you can do that by clicking
Toolsin the bottom left corner of Glitch, then clickingFull Page Console →. - In the console that opens, generate a new ssh key.
- When you're generating your SSH key, you'll be asked where you want to save it. You can go with the default location, but remember the file it's saved to. If you're not sure where it saved, it's probably in
~/.ssh/id_rsa.pubor/app/.ssh/id_rsa.pub. - Use the
catcommand to print out your newly-generated public key, then copy it. You'll need it for the next step. - Set up that public key as a deploy key for your forked GitHub repo.
- In your forked repo, set up a webhook to POST to
{your-project-name}.glitch.me/deploy?secret={your-secret}.- The Payload URL should be
{your-project-name}.glitch.me/deploy?secret={your-secret}. - Make sure
{your-secret}matches theSECRETenvironment variable you set earlier in your Glitch project. - Change the
Content typetoapplication/json. - You don't need to set the
Secretfield. That's a different, unrelated secret.
- The Payload URL should be
- Clone your forked repo to your computer.
- Change into the local copy of your repo that you just cloned.
- Create a git branch called
glitch.
Now when you push to the glitch branch of your repo, it will automatically get deployed to Glitch 🎉
☠️ Be careful. This project only checks if the
secretquery param matches theSECRETenvironment variable. It will happily pull down any git repository, including ones that don't belong to you.
Made by Thomas Bailey
\ ゜o゜)ノ