Skip to content
/ gd Public

Container deploy from GitHub registry via webhooks

Notifications You must be signed in to change notification settings

cloud-cli/gd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GD

Receive updates from GitHub webhooks

Events

With Cloudy, listen to events:

import { events } from '@cloud-cli/cli';

events.on('gd:command', command => { /* ... */ });

Commands

DeployCommand:

Contains a docker image published in GHCR and a version

Usage

First create a unique random string to use as secret. For example:

head -c 5000 /dev/urandom | sha512sum

Now paste this key into a file in your system. Let's use /home/key.txt.

Next, we create our http server to receive the webhooks:

import { createServer } '@cloud-cli/gd';
import { readFileSync } from 'fs';

const secret = readFileSync('/home/key.txt', 'utf-8');
const port = 1234;
const host = '127.0.0.1';

const server = createServer({ secret, host, port });
server.on('command', command => {
  console.log(command);
});

In GitHub, go to Webhook settings and point to your server using these settings:

Payload URL:
[ https://your-server.example.com/ ]

Content-Type:
[ application/json ]

Secret
[ secret string ]

Which events would you like to trigger this webhook?

[ * ] Let me select individual events.

...
[ x ] Branch or tag deletion
[ x ] Packages -- GitHub Packages published or updated in a repository.