Skip to content

Commit

Permalink
tryy
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrurodr committed Mar 7, 2022
1 parent 5cae8a0 commit a5aab64
Showing 1 changed file with 9 additions and 16 deletions.
25 changes: 9 additions & 16 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { endGroup, startGroup } from '@actions/core'
import * as github from '@actions/github'
//import axios, { AxiosError, AxiosRequestConfig, AxiosResponse } from 'axios'
import axios, { AxiosError, AxiosRequestConfig, AxiosResponse } from 'axios'
import { formatEvent } from './format'
import { HttpsProxyAgent } from 'https-proxy-agent'
import { getInputs, Inputs, statusOpts } from './input'
import { logDebug, logError, logInfo } from './utils'
import { fitEmbed } from './validate'
import createHttpsProxyAgent from 'https-proxy-agent'

async function run() {
try {
Expand Down Expand Up @@ -35,20 +35,13 @@ function wrapWebhook(webhook: string, payload: Object): Promise<void> {
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 ? { host, port } : {}
let options: any = {
method: 'POST',
body: JSON.stringify(payload),
headers: {'content-type': 'application/json'},
let proxy: any = host && port ? { proxy: { host, port }} : {}
if(fullProxy) {
const agent = new HttpsProxyAgent(fullProxy)
proxy = {...proxy, httpAgent: agent, httpsAgent: agent}
}
if(proxy) {
options = { ...options, agent: createHttpsProxyAgent(proxy) }

}
await fetch(webhook, options)

/*const client = axios.create(proxy)
/client.interceptors.request.use( (config: AxiosRequestConfig) => {
const client = axios.create(proxy)
client.interceptors.request.use( (config: AxiosRequestConfig) => {
logInfo(JSON.stringify(config))
return config
})
Expand All @@ -59,7 +52,7 @@ function wrapWebhook(webhook: string, payload: Object): Promise<void> {
logInfo(JSON.stringify(error))
return error
})
await client.post(webhook, payload) */
await client.post(webhook, payload)
} catch(e: any) {
if (e.response) {
logError(`Webhook response: ${e.response.status}: ${JSON.stringify(e.response.data)}`)
Expand Down

0 comments on commit a5aab64

Please sign in to comment.