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)}`)