Skip to content

Commit

Permalink
Initial Version
Browse files Browse the repository at this point in the history
  • Loading branch information
jessety committed Aug 3, 2020
1 parent 1414ac3 commit 0b16944
Show file tree
Hide file tree
Showing 20 changed files with 6,246 additions and 1 deletion.
18 changes: 18 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# https://editorconfig.org

root = true

[*]
charset = utf-8
end_of_line = lf

indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.{diff,patch}]
trim_trailing_whitespace = false
4 changes: 4 additions & 0 deletions .env.defaults
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
SECRET=
SCRIPT=
PORT=number=32490
VERBOSE=boolean=false
11 changes: 11 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "@jessety",
"overrides": [
{
"files": ["**/*.test.{js,cjs}"],
"parserOptions": { "sourceType": "script" },
"env": { "jest": true },
"rules": { "no-console": "warn" }
}
]
}
36 changes: 36 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: ci

on: [push]

jobs:

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: 14.x
- run: npm install
- run: npm run lint
env:
CI: true

test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
node: [14.x, 12.x]
steps:
- uses: actions/checkout@v2
- name: Use Node ${{ matrix.node }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- run: npm install
- run: npm run test
env:
CI: true
46 changes: 46 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: release

on:
push:
tags:
- 'v*' # Push events for tags matching v*, e.g. v1.0, v20.15.10

jobs:
build:
name: release
runs-on: ubuntu-latest
steps:

- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0 # git history won't be fetched without this option

- name: Setup Node
uses: actions/setup-node@v1

- name: Install Dependencies
run: npm install

- name: Generate Release Notes
run: npx auto-changelog --template RELEASE.md.hbs --output RELEASE.md --commit-limit false

- name: Parse Release Notes
id: parse
run: |
NOTES=$(cat RELEASE.md)
NOTES="${NOTES//'%'/'%25'}"
NOTES="${NOTES//$'\n'/'%0A'}"
echo "::set-output name=notes::$NOTES"
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
body: ${{ steps.parse.outputs.notes }}
draft: false
prerelease: false
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
node_modules
coverage
.env

RELEASE.md

**/*.swp
**/.DS_Store
**/.Spotlight-V100
**/[Tt]humbs.db
**/[Dd]esktop.ini
8 changes: 8 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"recommendations": [
"editorconfig.editorconfig",
"dbaeumer.vscode-eslint",
"mikestead.dotenv"
],
"unwantedRecommendations": []
}
9 changes: 9 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"search.exclude": {
"coverage:": true,
"node_modules": true
},
"files.associations": {
".env.defaults": "dotenv"
}
}
32 changes: 31 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,31 @@
# github-webhook
# github-webhook

A minimal GitHub webhook listener that executes a specified command when a release is published.

## Installation

```bash
git clone ...
cd github-webhook
npm install --production
pm2 start ecosystem.config.json
```

## Configuration

Edit an `.env` file in the project directory with the following options:

```ini
# GitHub Webhook Secret
SECRET=ABC123

# Script to execute when a release is published
SCRIPT=/usr/bin/local/update.sh

# Port to run the server on
PORT=32490
```

## License

MIT © Jesse Youngblood
16 changes: 16 additions & 0 deletions RELEASE.md.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{{#each releases}}
{{#if @first}}
{{#if summary}}
{{summary}}
{{/if}}
{{#each merges}}
- {{message}}{{#if href}} [`#{{id}}`]({{href}}){{/if}}
{{/each}}
{{#each fixes}}
- {{commit.subject}}{{#each fixes}}{{#if href}} [`#{{id}}`]({{href}}){{/if}}{{/each}}
{{/each}}
{{#each commits}}
- {{subject}}{{#if href}} [`{{shorthash}}`]({{href}}){{/if}}
{{/each}}
{{/if}}
{{/each}}
12 changes: 12 additions & 0 deletions ecosystem.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"apps": [{

"name": "github-webhook",

"cwd": "./",
"script": "src/index.js",

"watch": true,
"ignore_watch": [".git", "**/.DS_Store"]
}]
}
3 changes: 3 additions & 0 deletions jest.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"collectCoverageFrom": ["src/*.js"]
}
Loading

0 comments on commit 0b16944

Please sign in to comment.