Skip to content

Commit

Permalink
[command] npm run release
Browse files Browse the repository at this point in the history
  • Loading branch information
8398a7 committed Sep 21, 2021
2 parents 047b09b + 30fde7b commit c84a35c
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 11 deletions.
2 changes: 2 additions & 0 deletions __tests__/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ describe('8398a7/action-slack', () => {
beforeEach(() => {
process.env.GITHUB_REPOSITORY = '8398a7/action-slack';
process.env.GITHUB_EVENT_NAME = 'push';
process.env.https_proxy = 'http://localhost:1334';
process.env.HTTPS_PROXY = 'http://localhost:1334';
const github = require('@actions/github');
github.context.payload = {};
});
Expand Down
4 changes: 2 additions & 2 deletions dist/index.js

Large diffs are not rendered by default.

8 changes: 2 additions & 6 deletions package-lock.json

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

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "action-slack",
"version": "3.9.3",
"version": "3.10.0",
"description": "You can notify slack of GitHub Actions.",
"main": "lib/main.js",
"scripts": {
Expand Down Expand Up @@ -32,6 +32,7 @@
"@actions/core": "^1.4.0",
"@actions/github": "^5.0.0",
"@slack/webhook": "^6.0.0",
"https-proxy-agent": "^5.0.0",
"semver": "^7.3.5"
},
"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 c84a35c

Please sign in to comment.