Skip to content

Commit

Permalink
Switching back to legacy URL parsing as it is breaking in actions run…
Browse files Browse the repository at this point in the history
…ner environment
  • Loading branch information
peter-murray authored Oct 11, 2024
1 parent dc04139 commit 4ace3f2
Show file tree
Hide file tree
Showing 11 changed files with 191 additions and 163 deletions.
18 changes: 11 additions & 7 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
{
"name": "Workspace",
"image": "ghcr.io/octodemo/development-containers/javascript:base-202401-r1",
"extensions": [
"dbaeumer.vscode-eslint",
"redhat.vscode-yaml",
"swellaby.node-pack"
],
"postCreateCommand": "npm install"
"image": "ghcr.io/octodemo/development-containers/javascript-nodejs-20:base-202408-r2",
"postCreateCommand": "npm install",
"customizations": {
"vscode": {
"extensions": [
"dbaeumer.vscode-eslint",
"redhat.vscode-yaml",
"swellaby.node-pack"
],
}
}
}
8 changes: 4 additions & 4 deletions dist/main/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/main/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/main/sourcemap-register.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions dist/post/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/post/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/post/sourcemap-register.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ run();

function fail(err, message) {
core.error(err);
// Provide a debug controllable stack trace
core.debug(err.stack);

if (message) {
core.setFailed(message);
Expand Down
21 changes: 16 additions & 5 deletions lib/github-application.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const jwt = require('jsonwebtoken')
, core = require('@actions/core')
, PrivateKey = require('./private-key')
, HttpsProxyAgent = require('https-proxy-agent').HttpsProxyAgent
, URL = require('url')
, url = require('node:url')
;

module.exports.create = (privateKey, applicationId, baseApiUrl, timeout, proxy) => {
Expand Down Expand Up @@ -57,6 +57,7 @@ class GitHubApplication {
const token = jwt.sign(payload, this.privateKey, { algorithm: 'RS256' });
this._client = getOctokit(token, this._githubApiUrl, proxy);

core.debug(`Attempting to fetch GitHub Application...`);
return this.client.request('GET /app', {
mediaType: {
previews: ['machine-man']
Expand All @@ -68,6 +69,7 @@ class GitHubApplication {
// Store the metadata for debug purposes
self._metadata = resp.data;

core.debug(` GitHub Application resolved: ${JSON.stringify(resp.data)}`);
return resp.data;
} else {
throw new Error(`Failed to load application with id:${this.id}; ${resp.data}`);
Expand Down Expand Up @@ -234,12 +236,21 @@ function getProxyAgent(proxy, baseUrl) {
function proxyExcluded(noProxy, baseUrl) {
if (noProxy) {
const noProxyHosts = noProxy.split(',').map(part => part.trim());
const baseUrlHost = new URL(baseUrl).host;

core.debug(`noProxyHosts = ${JSON.stringify(noProxyHosts)}`);
core.debug(`baseUrlHost = ${baseUrlHost}`);

return noProxyHosts.indexOf(baseUrlHost) > -1;
core.debug(`parsing baseURL: '${baseUrl}'`);
// try {
// const parsedBaseUrl = new URL(baseUrl);
// core.debug(`parsed = ${parsedBaseUrl}`);
// core.debug(`base url host = '${parsedBaseUrl.host}'`);
// } catch (err) {
// core.error(`Failure in parsing the URL object`);
// throw err;
// }
const parsedBaseUrl = url.parse(baseUrl);
core.debug(`parsed host: ${[parsedBaseUrl.host]}`);

return noProxyHosts.indexOf(parsedBaseUrl.host) > -1;
}
}

Expand Down
Loading

0 comments on commit 4ace3f2

Please sign in to comment.