From 2a4e7227b5bb6ef619b7fd537d4e779c6d29bbe6 Mon Sep 17 00:00:00 2001 From: "Kozlak, TomaszX" Date: Tue, 19 Mar 2024 22:20:07 +0100 Subject: [PATCH 1/3] adapt code to use https_proxy proxy --- .github/workflows/test.yml | 68 ++++++++++++++++++-------------------- package-lock.json | 2 +- package.json | 6 ++-- src/main.ts | 10 +++++- 4 files changed, 46 insertions(+), 40 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e5ab47d..bd2986e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,49 +8,47 @@ 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 }} notification-summary: Deployment Started notification-color: 17a2b8 timezone: America/Denver - - uses: ./ - with: - github-token: ${{ github.token }} - ms-teams-webhook-uri: ${{ secrets.MS_TEAMS_WEBHOOK_URI }} - notification-summary: Warning! Something Not Quite Right - notification-color: ffc107 - timezone: America/Denver - - uses: ./ - with: - github-token: ${{ github.token }} - ms-teams-webhook-uri: ${{ secrets.MS_TEAMS_WEBHOOK_URI }} - notification-summary: OMG!! Something Exploded - notification-color: dc3545 - timezone: America/Denver - - uses: ./ - with: - github-token: ${{ github.token }} - ms-teams-webhook-uri: ${{ secrets.MS_TEAMS_WEBHOOK_URI }} - notification-summary: Whew! Everything is right with the world again! - notification-color: 28a745 - timezone: America/Denver - - uses: ./ - with: - github-token: ${{ github.token }} - ms-teams-webhook-uri: ${{ secrets.MS_TEAMS_WEBHOOK_URI }} - notification-summary: "Emojify! 🚢​​ ✅" - notification-color: 28a745 - timezone: America/Denver \ No newline at end of file + # - uses: ./ + # with: + # github-token: ${{ github.token }} + # ms-teams-webhook-uri: ${{ secrets.MS_TEAMS_WEBHOOK_URI }} + # notification-summary: Warning! Something Not Quite Right + # notification-color: ffc107 + # timezone: America/Denver + # - uses: ./ + # with: + # github-token: ${{ github.token }} + # ms-teams-webhook-uri: ${{ secrets.MS_TEAMS_WEBHOOK_URI }} + # notification-summary: OMG!! Something Exploded + # notification-color: dc3545 + # timezone: America/Denver + # - uses: ./ + # with: + # github-token: ${{ github.token }} + # ms-teams-webhook-uri: ${{ secrets.MS_TEAMS_WEBHOOK_URI }} + # notification-summary: Whew! Everything is right with the world again! + # notification-color: 28a745 + # timezone: America/Denver + # - uses: ./ + # with: + # github-token: ${{ github.token }} + # ms-teams-webhook-uri: ${{ secrets.MS_TEAMS_WEBHOOK_URI }} + # notification-summary: "Emojify! 🚢​​ ✅" + # notification-color: 28a745 + # timezone: America/Denver \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 58029ca..7df9f65 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,7 +21,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", diff --git a/package.json b/package.json index 0c26a24..74055ac 100644 --- a/package.json +++ b/package.json @@ -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": { @@ -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", diff --git a/src/main.ts b/src/main.ts index bf5cf7e..1b96555 100644 --- a/src/main.ts +++ b/src/main.ts @@ -3,6 +3,7 @@ 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'; const escapeMarkdownTokens = (text: string) => text @@ -34,7 +35,14 @@ async function run(): Promise { 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, 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}` From 12b07b7ce32c7d6a385a0b03d1bf7f8a1bcc2565 Mon Sep 17 00:00:00 2001 From: "Kozlak, TomaszX" Date: Tue, 19 Mar 2024 23:02:43 +0100 Subject: [PATCH 2/3] Specify variables type --- src/main.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main.ts b/src/main.ts index 1b96555..9adbe87 100644 --- a/src/main.ts +++ b/src/main.ts @@ -4,6 +4,7 @@ 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 @@ -36,7 +37,7 @@ async function run(): Promise { const runId = process.env.GITHUB_RUN_ID || '' const runNum = process.env.GITHUB_RUN_NUMBER || '' const proxyURI = process.env.https_proxy || process.env.HTTPS_PROXY || '' - const myFetch = (url, options) => { + const myFetch = (url: string, options: Options) => { return undiciFetch(url, { ...options, dispatcher: new ProxyAgent({uri: proxyURI}) From f93605959e5039efbff0e831217bdfd449f10c7a Mon Sep 17 00:00:00 2001 From: ktomaszx <99728548+ktomaszx@users.noreply.github.com> Date: Tue, 19 Mar 2024 23:08:57 +0100 Subject: [PATCH 3/3] Update test.yml --- .github/workflows/test.yml | 56 +++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bd2986e..a1cbea8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -24,31 +24,31 @@ jobs: notification-summary: Deployment Started notification-color: 17a2b8 timezone: America/Denver - # - uses: ./ - # with: - # github-token: ${{ github.token }} - # ms-teams-webhook-uri: ${{ secrets.MS_TEAMS_WEBHOOK_URI }} - # notification-summary: Warning! Something Not Quite Right - # notification-color: ffc107 - # timezone: America/Denver - # - uses: ./ - # with: - # github-token: ${{ github.token }} - # ms-teams-webhook-uri: ${{ secrets.MS_TEAMS_WEBHOOK_URI }} - # notification-summary: OMG!! Something Exploded - # notification-color: dc3545 - # timezone: America/Denver - # - uses: ./ - # with: - # github-token: ${{ github.token }} - # ms-teams-webhook-uri: ${{ secrets.MS_TEAMS_WEBHOOK_URI }} - # notification-summary: Whew! Everything is right with the world again! - # notification-color: 28a745 - # timezone: America/Denver - # - uses: ./ - # with: - # github-token: ${{ github.token }} - # ms-teams-webhook-uri: ${{ secrets.MS_TEAMS_WEBHOOK_URI }} - # notification-summary: "Emojify! 🚢​​ ✅" - # notification-color: 28a745 - # timezone: America/Denver \ No newline at end of file + - uses: ./ + with: + github-token: ${{ github.token }} + ms-teams-webhook-uri: ${{ secrets.MS_TEAMS_WEBHOOK_URI }} + notification-summary: Warning! Something Not Quite Right + notification-color: ffc107 + timezone: America/Denver + - uses: ./ + with: + github-token: ${{ github.token }} + ms-teams-webhook-uri: ${{ secrets.MS_TEAMS_WEBHOOK_URI }} + notification-summary: OMG!! Something Exploded + notification-color: dc3545 + timezone: America/Denver + - uses: ./ + with: + github-token: ${{ github.token }} + ms-teams-webhook-uri: ${{ secrets.MS_TEAMS_WEBHOOK_URI }} + notification-summary: Whew! Everything is right with the world again! + notification-color: 28a745 + timezone: America/Denver + - uses: ./ + with: + github-token: ${{ github.token }} + ms-teams-webhook-uri: ${{ secrets.MS_TEAMS_WEBHOOK_URI }} + notification-summary: "Emojify! 🚢​​ ✅" + notification-color: 28a745 + timezone: America/Denver