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.env
with the contents of.env.example
there. After doing this, the.env.example
on Glitch can be deleted. - Clone your fork from GitHub to your computer.
- In your local project, rename
.env.example
to.env
. - In your computer's terminal,
cd
to your project root directory and runnpm run mksecret
. Copy the output hex string and paste it as the value toSECRET
in the.env
file, 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 ofSECRET
in the.env
file, and triggering events as "Just thepush
event.". - 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
nodemon
runnpm run dev
. Otherwise,npm start
.
- By default, the Glitch project will pull from the repo
master
branch. If you create additional branches in your repo and want it to pull from a different one, just uncomment thePULL_BRANCH
variable in the project.env
file 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.css
andviews/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゜)ノ