Giter VIP home page Giter VIP logo

ghcr-hook's Introduction

GHCR-Hook

workflow

Keep your local Docker images & containers in sync with GitHub's Container Registry using webhooks.

The server reacts to webhooks from GitHub with the event package.published. If everything checks out it proceeds to download the new image & restart every container with the same configuration it was started except for the new image.

Limitations

  • There has to be at least one Container running using the image to be reloaded.
  • Currently does not support versioned images. E.g. upgrade from 1.1 to 1.2 wont work.
  • If something goes wrong there is no recovery!

Usage

Configuration

Required

  • WEBHOOK_SECRET (or WEBHOOK_SECRET_FILE)

For full configuration & defaults see: src/utils/config.ts

Run with Docker

Create webhook secret.

echo $(openssl rand -base64 32 | tr -d '\n') > webhook.secret

Create docker-compose.yml.

version: '3.8'

secrets:
  webhook:
    file: ./webhook.secret

services:
  webhooks:
    image: ghcr.io/lucarickli/ghcr-hook
    secrets:
      - webhook
    environment:
      WEBHOOK_SECRET_FILE: /run/secrets/webhook
      # Can also be set without docker secret.
      # WEBHOOK_SECRET: ${WEBHOOK_SECRET:?WEBHOOK_SECRET is required!}
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ./logs:/home/logs
    ports:
      - 8000:8000

Start container.

docker compose up

Run locally

cp example.env .env

Edit WEBHOOK_SECRET inside .env to prevent attackers from accessing this endpoint!

npm i
npm run build
npm start

Development

npm run dev
npm run dev:debug # With debugging

Add container to sync

  1. Pull the docker image you want to sync to your server.
  2. Start at least one container using this image.
  3. Add a webhook to your GitHub repo.
    • Set Payload Url to your server.
    • Set Webhook Secret to your generated secret.
    • Set Content type to applications/json.
    • Select individual events and remove everything except packages.

Todo's

  • Add version control with downgrade protection.

ghcr-hook's People

Contributors

dependabot[bot] avatar lucarickli avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.