GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - plibither8/github-hook-script-runner: 🪝 Run a shell script on your machine when you push to a repository - a mini, self-hosted CI/CD 💚

BranchesTags
Open more actions menu

Latest commit

 

History

1 Commit
1 Commit

Folders and files

NameName
Last commit message
Last commit date
.env.example
.env.example
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
index.js
index.js
 
 
package.json
package.json
 
 
pnpm-lock.yaml
pnpm-lock.yaml
 
 
script.sh
script.sh
 
 

Repository files navigation

🪝 GitHub Webhook Script Runner

Run a shell script when you push to a repository - a mini, self-hosted CI/CD 💚

Quickly start up a server that listens to webhooks requests, and run a shell script when you push to your repository on GitHub.

This is most useful when your project is running on a personal VPS (EC2, Droplets, etc.) and you want to relieve yourself of git pulling and npm run building every time.

Setup

  1. Clone this repo or use the template to create a new repo

  2. Setup environment variables: cp .env.example .env:

    PORT: The port at which this server will run
    WEBHOOK_SECRET: Secret key to encrypt and validate webhook requests. It can be anything, make sure it's secure.
    REPO_PATH: Path (to the repository) where you want to run the script

  3. Install dependencies and start the server:

    npm install
    npm start

    The server is now listening on ${PORT}.

  4. Configure a (sub)domain for this server. Can easily be achieved by using something like Nginx to reverse proxy requests to this server. Let's assume our domain is hooks.example.com.

  5. Setup the repository's webhook on GitHub:

    • Go to settings/webhooks in the repository
    • Create a new webhook with:
      • Domain: https://hooks.example.com
      • Webhook secret: WEBHOOK_SECRET in the .env file
      • Content type: application/json
      • push type event
  6. 🎉 It should be setup now and running! You can view the "Recent deliveries" of the webhook inside the webhook settings on GitHub to check whether you have received a 200 response with Script started.. Debug on your own :P.

Example script

An example script for a basic Node webapp would be:

cd $1                   # cd into the repo's directory
git stash               # stash any changes
git pull origin master  # pull the latest commits
npm install             # install new packages, if any
npm run build           # build production bundles
npm run start           # start the server

License

MIT

About

🪝 Run a shell script on your machine when you push to a repository - a mini, self-hosted CI/CD 💚

Topics

ci-cdgithubgithub-hooksgithub-webhooks

Resources

Readme
MIT license
Activity

Stars

5 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.