Skip to content

Commit

Permalink
version
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrurodr committed Mar 7, 2022
1 parent a5aab64 commit c715dc2
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.getPayload = void 0;
const core_1 = require("@actions/core");
const github = __importStar(require("@actions/github"));
const axios_1 = __importDefault(require("axios"));
const format_1 = require("./format");
const https_proxy_agent_1 = require("https-proxy-agent");
const input_1 = require("./input");
const utils_1 = require("./utils");
const validate_1 = require("./validate");
const https_proxy_agent_1 = __importDefault(require("https-proxy-agent"));
function run() {
return __awaiter(this, void 0, void 0, function* () {
try {
Expand Down Expand Up @@ -68,16 +69,24 @@ function wrapWebhook(webhook, payload) {
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 = {
method: 'POST',
body: JSON.stringify(payload),
headers: { 'content-type': 'application/json' },
};
if (proxy) {
options = Object.assign(Object.assign({}, options), { agent: https_proxy_agent_1.default(proxy) });
let proxy = host && port ? { proxy: { host, port } } : {};
if (fullProxy) {
const agent = new https_proxy_agent_1.HttpsProxyAgent(fullProxy);
proxy = Object.assign(Object.assign({}, proxy), { httpAgent: agent, httpsAgent: agent });
}
yield fetch(webhook, options);
const client = axios_1.default.create(proxy);
client.interceptors.request.use((config) => {
utils_1.logInfo(JSON.stringify(config));
return config;
});
client.interceptors.response.use((axiosResponse) => {
utils_1.logInfo(JSON.stringify(axiosResponse));
return axiosResponse;
}, (error) => {
utils_1.logInfo(JSON.stringify(error));
return error;
});
yield client.post(webhook, payload);
}
catch (e) {
if (e.response) {
Expand Down

0 comments on commit c715dc2

Please sign in to comment.