mirror of
https://github.com/joelwmale/webhook-action.git
synced 2026-08-24 00:49:00 +08:00
Allow optional headers & body
This commit is contained in:
+5
-3
@@ -10,12 +10,14 @@ class Http {
|
||||
|
||||
getOptions(method: string, headers: string, body: string) {
|
||||
const options: any = {
|
||||
headers: JSON.parse(headers),
|
||||
headers: headers ? JSON.parse(headers) : {},
|
||||
method
|
||||
};
|
||||
|
||||
// stringify the body
|
||||
options.body = JSON.stringify(body);
|
||||
if (body) {
|
||||
// parse the body
|
||||
options.body = body;
|
||||
}
|
||||
|
||||
// set these headers
|
||||
options.headers['content-type'] = 'application/json';
|
||||
|
||||
+2
-2
@@ -3,8 +3,8 @@ import { http } from './http';
|
||||
|
||||
async function run() {
|
||||
const url = core.getInput('url');
|
||||
const headers = core.getInput('headers') ?? '';
|
||||
const body = core.getInput('body') ?? '';
|
||||
const headers = core.getInput('headers') ?? null;
|
||||
const body = core.getInput('body') ?? null;
|
||||
|
||||
// initial info
|
||||
core.info(`Sending webhook request to ${url}`);
|
||||
|
||||
Reference in New Issue
Block a user