Skip to content

Commit

Permalink
Add ability to get it working with proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
sethuk07 committed Jun 11, 2021
1 parent 6c319ca commit ae03720
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
1 change: 1 addition & 0 deletions dist/index.js

Large diffs are not rendered by default.

15 changes: 4 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"@actions/core": "^1.2.6",
"@actions/github": "^4.0.0",
"@slack/webhook": "^5.0.4",
"https-proxy-agent": "^4.0.0",
"semver": "^7.3.4"
},
"devDependencies": {
Expand Down
16 changes: 14 additions & 2 deletions src/client.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import * as core from '@actions/core';
import { context, getOctokit } from '@actions/github';
import { GitHub } from '@actions/github/lib/utils';
import { IncomingWebhook, IncomingWebhookSendArguments } from '@slack/webhook';
import {
IncomingWebhook,
IncomingWebhookSendArguments,
IncomingWebhookDefaultArguments,
} from '@slack/webhook';
import { FieldFactory } from './fields';
import HttpsProxyAgent from 'https-proxy-agent';

export const Success = 'success';
type SuccessType = 'success';
Expand Down Expand Up @@ -58,7 +63,14 @@ export class Client {
if (webhookUrl === undefined || webhookUrl === null || webhookUrl === '') {
throw new Error('Specify secrets.SLACK_WEBHOOK_URL');
}
this.webhook = new IncomingWebhook(webhookUrl);

const options: IncomingWebhookDefaultArguments = {};
const proxy = process.env.https_proxy || process.env.HTTPS_PROXY;
if (proxy) {
options.agent = new HttpsProxyAgent(proxy);
}

this.webhook = new IncomingWebhook(webhookUrl, options);
this.fieldFactory = new FieldFactory(
this.with.fields,
this.jobName,
Expand Down

0 comments on commit ae03720

Please sign in to comment.