Skip to content

Commit

Permalink
Merge pull request #674 from joelwmale/develop
Browse files Browse the repository at this point in the history
v2.3.0
  • Loading branch information
joelwmale authored Mar 28, 2024
2 parents 448a17b + 6bfee79 commit 0a169d9
Show file tree
Hide file tree
Showing 4,370 changed files with 47,403 additions and 1,590,730 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
dist/
dist
node_nodules
25 changes: 20 additions & 5 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,33 @@
{
"env": {
"commonjs": true,
"node": true,
"es6": true,
"jest": true,
"node": true
"jest": true
},
"extends": "eslint:recommended",
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2018
"ecmaVersion": 9,
"sourceType": "module",
"project": "./tsconfig.json"
},
"plugins": [
"jest",
"@typescript-eslint"
],
"extends": [
"plugin:github/recommended",
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
"rules": {
"@typescript-eslint/no-explicit-any": "off",
"github/no-then": "off",
"import/no-namespace": "off",
"i18n-text/no-en": "off"
}
}
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ updates:
directory: "/"
# Check the npm registry for updates every day (weekdays)
schedule:
interval: "daily"
interval: "weekly"
9 changes: 0 additions & 9 deletions .github/mergify.yml

This file was deleted.

40 changes: 40 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Tests

on:
push:
branches:
- master
- develop
pull_request:
branches:
- master
release:
types:
- created

jobs:
tests:
name: Tests
runs-on: ubuntu-20.04

strategy:
fail-fast: true
matrix:
node-version: [20.x]
stability: [prefer-stable]

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'

- name: Install dependencies
run: yarn install --frozen-lockfile --${{ matrix.stability }}

- name: Execute tests
run: yarn test
54 changes: 1 addition & 53 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,53 +1 @@
# Rest pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# DynamoDB Local files
.dynamodb/

# OS metadata
.DS_Store
Thumbs.db

# Ignore built ts files
__tests__/runner/*
lib/**/*
node_modules/*
42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Example:
url: ${{ secrets.WEBHOOK_URL }}
headers: '{"repository": "joelwmale/webhook-action"}'
body: '{"event": "deployment", "repository": "joelwmale/webhook-action"}'
github_event_payload: true
```
It is **highly** recommended to use the action is an explicit commit SHA-1:
Expand All @@ -34,11 +35,28 @@ The action has support for the following input variables (arguments):
* **`headers`** (**optional**): Any headers you want to be sent with the webhook
* **`body`** (**optional**): The body of data send with the webhook
* **`insecure`** (**optional**): Enables calling to known self-signed or invalid SSL certificates
* **`github_event_payload`** (**optional**): Enables forwarding the Github event payload to your webhook.

You can find more information on how to use these input variables below.

## Arguments

#### URL

**Required:** true

The URL to send the webhook to

```yml
url: ${{ secrets.WEBHOOK_URL }}
```

or

```yml
url: https://webhook.site/8b1b1b1b-8b1b-8b1b-8b1b-8b1b1b1b1b1b
```

#### Headers

**Required:** false
Expand All @@ -60,6 +78,30 @@ Allows you to send a custom JSON object to the webhook
body: '{"event": "deployment", "repository": "joelwmale/webhook-action"}'
```

#### Insecure

**Required:** false
**Default:** false

Allows you to send a webhook to a known self-signed or invalid SSL certificate

```yml
insecure: true
```

#### Github Event Payload

**Required:** false
**Default:** false

Allows you to send the Github event payload to your webhook

The payload will be sent as a JSON object under the key `githubEventPayload` on the root of the payload sent to your webhook

```yml
github_event_payload: true
```

## Issues

If you find any issues or have an improvement feel free to [submit an issue](https://github.com/joelwmale/webhook-action/issues/new)
Expand Down
31 changes: 31 additions & 0 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import {http} from '../src/http'
import {expect, test} from '@jest/globals'

test('it makes a post request', async () => {
const url = 'https://httpbin.org/post'
const body = '{"hello": "world"}'
const res = await http.make(url, body)
expect(res.status).toBe(200)
})

test('it makes a post request with insecure', async () => {
const url = 'https://httpbin.org/post'
const body = '{"hello": "world"}'
const insecure = true
const res = await http.make(url, body, null, insecure)
expect(res.status).toBe(200)
})

test('it makes a post request with headers', async () => {
const url = 'https://httpbin.org/post'
const body = '{"hello": "world"}'
const headers = '{"Content-Type": "application/json"}'
const res = await http.make(url, body, headers)
expect(res.status).toBe(200)
})

test('it doesnt require a body', async () => {
const url = 'https://httpbin.org/post'
const res = await http.make(url, null)
expect(res.status).toBe(200)
})
6 changes: 5 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@ inputs:
insecure:
description: 'Enables calling to known self-signed or invalid SSL certificates'
required: false
github_event_payload:
description: 'Include the github event payload that triggered the action in the payload'
required: false
outputs:
status:
description: 'The status of the webhook event'
runs:
using: 'node16'
using: 'node20'
main: 'dist/index.js'
post: 'dist/index.js'
1 change: 1 addition & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = {presets: ['@babel/preset-env']}
Loading

0 comments on commit 0a169d9

Please sign in to comment.