Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add proxy support #67

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,16 @@ on: # rebuild any PRs and main branch changes
- 'releases/*'

jobs:
build: # make sure build/ci work properly
build_and_test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: |
- name: Build
run: |
npm install
npm run all
test: # make sure the action works on a clean machine without building
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./
- name: Test
uses: ./
with:
github-token: ${{ github.token }}
ms-teams-webhook-uri: ${{ secrets.MS_TEAMS_WEBHOOK_URI }}
Expand Down Expand Up @@ -53,4 +51,4 @@ jobs:
ms-teams-webhook-uri: ${{ secrets.MS_TEAMS_WEBHOOK_URI }}
notification-summary: "Emojify! &#x1F6A2​​ ✅"
notification-color: 28a745
timezone: America/Denver
timezone: America/Denver
2 changes: 1 addition & 1 deletion package-lock.json

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

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
"description": "TypeScript template action",
"main": "lib/main.js",
"scripts": {
"build": "set NODE_OPTIONS=--openssl-legacy-provider tsc",
"build": "export NODE_OPTIONS=--openssl-legacy-provider && tsc",
"format": "prettier --write **/*.ts",
"format-check": "prettier --check **/*.ts",
"pack": "set NODE_OPTIONS=--openssl-legacy-provider ncc build",
"pack": "export NODE_OPTIONS=--openssl-legacy-provider && ncc build",
"all": "npm run build && npm run format && npm run pack"
},
"repository": {
Expand All @@ -35,7 +35,7 @@
"@types/moment-timezone": "^0.5.30",
"@types/node": "^16.11.7",
"@typescript-eslint/parser": "^5.47.0",
"@zeit/ncc": "^0.20.5",
"@vercel/ncc": "^0.38.0",
"eslint": "^8.30.0",
"eslint-plugin-github": "^4.6.0",
"eslint-plugin-jest": "^27.1.7",
Expand Down
11 changes: 10 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import {Octokit} from '@octokit/rest'
import axios from 'axios'
import moment from 'moment-timezone'
import {createMessageCard} from './message-card'
import { fetch as undiciFetch, ProxyAgent } from 'undici';
import Options from 'undici/types/dispatcher';

const escapeMarkdownTokens = (text: string) =>
text
Expand Down Expand Up @@ -34,7 +36,14 @@ async function run(): Promise<void> {
const sha = process.env.GITHUB_SHA || ''
const runId = process.env.GITHUB_RUN_ID || ''
const runNum = process.env.GITHUB_RUN_NUMBER || ''
const params = {owner, repo, ref: sha}
const proxyURI = process.env.https_proxy || process.env.HTTPS_PROXY || ''
const myFetch = (url: string, options: Options) => {
return undiciFetch(url, {
...options,
dispatcher: new ProxyAgent({uri: proxyURI})
})
}
const params = {owner, repo, ref: sha, request: { fetch: myFetch }}
const repoName = params.owner + '/' + params.repo
const repoUrl = `https://github.com/${repoName}`

Expand Down