This simple app adds a GitHub Webhook endpoint to Glitch's hello-express app, that employs HMAC signature verification to deploy to Glitch upon push events from a GitHub repository.
Inspired by Git Glitched, code for the endpoint route is adapted from this article.
- Fork this repo on GitHub.
- On Glitch, create a new project with the option to "Clone from Git Repo", using the git URL from your newly created fork (e.g.
https://github.com/username/reponame.git). When the new project loads, replace the contents of.envwith the contents of.env.examplethere. After doing this, the.env.exampleon Glitch can be deleted. - Clone your fork from GitHub to your computer.
- In your local project, rename
.env.exampleto.env. - In your computer's terminal,
cdto your project root directory and runnpm run mksecret. Copy the output hex string and paste it as the value toSECRETin the.envfile, both in your local project and on Glitch. - Back in your GitHub repo's webhooks settings (
https://github.com/username/reponame/settings/hooks), create a new webhook setting the payload URL to your Glitch project's endpoint (https://your-project-name.glitch.me/glitch-deploy), content type toapplication/json, secret to the value ofSECRETin the.envfile, and triggering events as "Just thepushevent.". - Now you're ready to go! When you push to GitHub from your local project, the webhook will automatically notify your Glitch project to pull in the new changes.
- Install dependencies with
npm install. - To start the app with
nodemonrunnpm run dev. Otherwise,npm start.
- By default, the Glitch project will pull from the repo
masterbranch. If you create additional branches in your repo and want it to pull from a different one, just uncomment thePULL_BRANCHvariable in the project.envfile on Glitch (this file is untracked), and add your preferred branch as the value (e.g.PULL_BRANCH=glitch).
Click Show in the header to see your app live. Updates to your code will instantly deploy and update live.
Glitch is the friendly community where you'll build the app of your dreams. Glitch lets you instantly create, remix, edit, and host an app, bot or site, and you can invite collaborators or helpers to simultaneously edit code with you.
Find out more about Glitch.
On the front-end,
- edit
public/client.js,public/style.cssandviews/index.html - drag in
assets, like images or music, to add them to your project
On the back-end,
- your app starts at
server.js - add frameworks and packages in
package.json - safely store app secrets in
.env(nobody can see this but you and people you invite)
Made by Glitch
\ ゜o゜)ノ