This commit is contained in:
Joel Male
2020-08-27 18:23:33 +10:00
parent 9fa1db0dd2
commit 01d242f5b1
109 changed files with 198798 additions and 322059 deletions
+2 -2
View File
@@ -1,14 +1,14 @@
const fetch = require('node-fetch');
class Http {
make(url: string, headers: string, body: string): Promise<any> {
make(url: string, headers: string|null, body: string|null): Promise<any> {
return new Promise((resolve, reject) => {
fetch(url, this.getOptions('post', headers, body))
.then((res: Response) => resolve(res));
});
}
getOptions(method: string, headers: string, body: string) {
getOptions(method: string, headers: string|null, body: string|null) {
const options: any = {
headers: headers ? JSON.parse(headers) : {},
method
+9 -3
View File
@@ -2,9 +2,15 @@ import * as core from '@actions/core';
import { http } from './http';
async function run() {
const url = core.getInput('url') ?? process.env.WEBHOOK_URL;
const headers = core.getInput('headers') ?? process.env.HEADERS ?? null;
const body = core.getInput('body') ?? process.env.data ?? null;
const url = core.getInput('url') ? core.getInput('url') : (process.env.url ? process.env.url : '');
const headers = core.getInput('headers') ? core.getInput('headers') : (process.env.headers ? process.env.headers : null);
const body = core.getInput('body') ? core.getInput('body') : (process.env.body ? process.env.body : null);
if (!url) {
// validate a url
core.setFailed('A url is required to run this action.');
return;
}
// initial info
core.info(`Sending webhook request to ${url}`);