From 66745c29a2532b1b8e555d156bf81707bb66f4e5 Mon Sep 17 00:00:00 2001 From: andrurodr Date: Fri, 4 Mar 2022 12:44:02 -0300 Subject: [PATCH] new try --- src/main.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main.ts b/src/main.ts index 66438f27..06067b19 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,6 +1,6 @@ import { endGroup, startGroup } from '@actions/core' import * as github from '@actions/github' -import axios from 'axios' +import axios, { AxiosRequestConfig } from 'axios' import { formatEvent } from './format' import { getInputs, Inputs, statusOpts } from './input' import { logDebug, logError, logInfo } from './utils' @@ -34,8 +34,13 @@ function wrapWebhook(webhook: string, payload: Object): Promise { const fullProxy = process.env['http_proxy'] || process.env['HTTP_PROXY'] || process.env['https_proxy'] || process.env['HTTPS_PROXY'] const host = fullProxy ? fullProxy.split(':')[0] : '' const port = fullProxy ? parseInt(fullProxy.split(':')[1]) : '' - const proxy = host && port ? {proxy:{host, port}} : {} - await axios.post(webhook, payload, proxy) + const proxy = host && port ? {proxy:{host, port}} : {} + const client = axios.create(proxy) + client.interceptors.request.use( (config: AxiosRequestConfig) => { + logInfo(JSON.stringify(config)) + return config + }) + await client.post(webhook, payload) } catch(e: any) { if (e.response) { logError(`Webhook response: ${e.response.status}: ${JSON.stringify(e.response.data)}`)