@@ -7217,7 +7217,7 @@ Object.defineProperty(Response.prototype, Symbol.toStringTag, {
72177217});
72187218
72197219const INTERNALS$2 = Symbol('Request internals');
7220- const URL = whatwgUrl.URL;
7220+ const URL = Url.URL || whatwgUrl.URL;
72217221
72227222// fix an issue where "format", "parse" aren't a named export for node <10
72237223const parse_url = Url.parse;
@@ -7480,9 +7480,17 @@ AbortError.prototype = Object.create(Error.prototype);
74807480AbortError.prototype.constructor = AbortError;
74817481AbortError.prototype.name = 'AbortError';
74827482
7483+ const URL$1 = Url.URL || whatwgUrl.URL;
7484+
74837485// fix an issue where "PassThrough", "resolve" aren't a named export for node <10
74847486const PassThrough$1 = Stream.PassThrough;
7485- const resolve_url = Url.resolve;
7487+
7488+ const isDomainOrSubdomain = function isDomainOrSubdomain(destination, original) {
7489+ const orig = new URL$1(original).hostname;
7490+ const dest = new URL$1(destination).hostname;
7491+
7492+ return orig === dest || orig[orig.length - dest.length - 1] === '.' && orig.endsWith(dest);
7493+ };
74867494
74877495/**
74887496 * Fetch function
@@ -7570,7 +7578,19 @@ function fetch(url, opts) {
75707578 const location = headers.get('Location');
75717579
75727580 // HTTP fetch step 5.3
7573- const locationURL = location === null ? null : resolve_url(request.url, location);
7581+ let locationURL = null;
7582+ try {
7583+ locationURL = location === null ? null : new URL$1(location, request.url).toString();
7584+ } catch (err) {
7585+ // error here can only be invalid URL in Location: header
7586+ // do not throw when options.redirect == manual
7587+ // let the user extract the errorneous redirect URL
7588+ if (request.redirect !== 'manual') {
7589+ reject(new FetchError(`uri requested responds with an invalid redirect URL: ${location}`, 'invalid-redirect'));
7590+ finalize();
7591+ return;
7592+ }
7593+ }
75747594
75757595 // HTTP fetch step 5.5
75767596 switch (request.redirect) {
@@ -7618,6 +7638,12 @@ function fetch(url, opts) {
76187638 size: request.size
76197639 };
76207640
7641+ if (!isDomainOrSubdomain(request.url, locationURL)) {
7642+ for (const name of ['authorization', 'www-authenticate', 'cookie', 'cookie2']) {
7643+ requestOpts.headers.delete(name);
7644+ }
7645+ }
7646+
76217647 // HTTP-redirect fetch step 9
76227648 if (res.statusCode !== 303 && request.body && getTotalBytes(request) === null) {
76237649 reject(new FetchError('Cannot follow redirect with body being a readable stream', 'unsupported-redirect'));
@@ -22576,9 +22602,25 @@ function sync (path, options) {
2257622602// ignored, since we can never get coverage for them.
2257722603// grab a reference to node's real process object right away
2257822604var process = global.process
22605+
22606+ const processOk = function (process) {
22607+ return process &&
22608+ typeof process === 'object' &&
22609+ typeof process.removeListener === 'function' &&
22610+ typeof process.emit === 'function' &&
22611+ typeof process.reallyExit === 'function' &&
22612+ typeof process.listeners === 'function' &&
22613+ typeof process.kill === 'function' &&
22614+ typeof process.pid === 'number' &&
22615+ typeof process.on === 'function'
22616+ }
22617+
2257922618// some kind of non-node environment, just no-op
22580- if (typeof process !== 'object' || !process) {
22581- module.exports = function () {}
22619+ /* istanbul ignore if */
22620+ if (!processOk(process)) {
22621+ module.exports = function () {
22622+ return function () {}
22623+ }
2258222624} else {
2258322625 var assert = __webpack_require__(357)
2258422626 var signals = __webpack_require__(187)
@@ -22609,8 +22651,9 @@ if (typeof process !== 'object' || !process) {
2260922651 }
2261022652
2261122653 module.exports = function (cb, opts) {
22612- if (global.process !== process) {
22613- return
22654+ /* istanbul ignore if */
22655+ if (!processOk(global.process)) {
22656+ return function () {}
2261422657 }
2261522658 assert.equal(typeof cb, 'function', 'a callback must be provided for exit handler')
2261622659
@@ -22636,7 +22679,7 @@ if (typeof process !== 'object' || !process) {
2263622679 }
2263722680
2263822681 var unload = function unload () {
22639- if (!loaded || global.process !== process ) {
22682+ if (!loaded || !processOk( global.process) ) {
2264022683 return
2264122684 }
2264222685 loaded = false
@@ -22653,6 +22696,7 @@ if (typeof process !== 'object' || !process) {
2265322696 module.exports.unload = unload
2265422697
2265522698 var emit = function emit (event, code, signal) {
22699+ /* istanbul ignore if */
2265622700 if (emitter.emitted[event]) {
2265722701 return
2265822702 }
@@ -22664,7 +22708,8 @@ if (typeof process !== 'object' || !process) {
2266422708 var sigListeners = {}
2266522709 signals.forEach(function (sig) {
2266622710 sigListeners[sig] = function listener () {
22667- if (process !== global.process) {
22711+ /* istanbul ignore if */
22712+ if (!processOk(global.process)) {
2266822713 return
2266922714 }
2267022715 // If there are no other listeners, an exit is coming!
@@ -22683,6 +22728,7 @@ if (typeof process !== 'object' || !process) {
2268322728 // so use a supported signal instead
2268422729 sig = 'SIGINT'
2268522730 }
22731+ /* istanbul ignore next */
2268622732 process.kill(process.pid, sig)
2268722733 }
2268822734 }
@@ -22695,7 +22741,7 @@ if (typeof process !== 'object' || !process) {
2269522741 var loaded = false
2269622742
2269722743 var load = function load () {
22698- if (loaded || process !== global.process) {
22744+ if (loaded || !processOk( global.process) ) {
2269922745 return
2270022746 }
2270122747 loaded = true
@@ -22722,10 +22768,11 @@ if (typeof process !== 'object' || !process) {
2272222768
2272322769 var originalProcessReallyExit = process.reallyExit
2272422770 var processReallyExit = function processReallyExit (code) {
22725- if (process !== global.process) {
22771+ /* istanbul ignore if */
22772+ if (!processOk(global.process)) {
2272622773 return
2272722774 }
22728- process.exitCode = code || 0
22775+ process.exitCode = code || /* istanbul ignore next */ 0
2272922776 emit('exit', process.exitCode, null)
2273022777 /* istanbul ignore next */
2273122778 emit('afterexit', process.exitCode, null)
@@ -22735,14 +22782,17 @@ if (typeof process !== 'object' || !process) {
2273522782
2273622783 var originalProcessEmit = process.emit
2273722784 var processEmit = function processEmit (ev, arg) {
22738- if (ev === 'exit' && process === global.process) {
22785+ if (ev === 'exit' && processOk(global.process)) {
22786+ /* istanbul ignore else */
2273922787 if (arg !== undefined) {
2274022788 process.exitCode = arg
2274122789 }
2274222790 var ret = originalProcessEmit.apply(this, arguments)
22791+ /* istanbul ignore next */
2274322792 emit('exit', process.exitCode, null)
2274422793 /* istanbul ignore next */
2274522794 emit('afterexit', process.exitCode, null)
22795+ /* istanbul ignore next */
2274622796 return ret
2274722797 } else {
2274822798 return originalProcessEmit.apply(this, arguments)
@@ -26168,8 +26218,12 @@ module.exports = require("zlib");
2616826218//
2616926219// After changing this file, use `ncc build index.js` to rebuild to dist/
2617026220
26221+ // Refs:
26222+ // https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#status
26223+
2617126224const core = __webpack_require__(996)
2617226225const github = __webpack_require__(828)
26226+ const fetch = __webpack_require__(366);
2617326227
2617426228async function run() {
2617526229 try {
@@ -26183,25 +26237,37 @@ async function run() {
2618326237 }
2618426238 const prepender = x => 'ci/circleci: ' + x
2618526239 circleciJobs = circleciJobs.split(',').map(prepender)
26186- core.debug('Considering CircleCI jobs named:')
26187- core.debug(circleciJobs)
26240+ core.debug(`Considering CircleCI jobs named: ${circleciJobs}`)
2618826241 if (circleciJobs.indexOf(payload.context) < 0) {
26189- core.debug('Ignoring context:')
26190- core.debug(payload.context)
26242+ core.debug(`Ignoring context: ${payload.context}`)
2619126243 return
2619226244 }
26193- core.debug('Processing context and state:')
26194- core.debug(payload.context)
26195- core.debug(payload.state)
26196- // Set the new status
2619726245 const state = payload.state
26198- const buildId = payload.target_url.split('?')[0].split('/').slice(-1)[0]
26199- const repoId = payload.repository.id
26200- const url = 'https://' + buildId + '-' + repoId + '-gh.circle-artifacts.com/' + path
26201- core.debug('Linking to:')
26202- core.debug(url)
26246+ core.debug(`context: ${payload.context}`)
26247+ core.debug(`state: ${state}`)
26248+ core.debug(`target_url: ${payload.target_url}`)
26249+ // e.g., https://circleci.com/gh/larsoner/circleci-artifacts-redirector-action/94?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link
26250+ // Set the new status
26251+ const parts = payload.target_url.split('?')[0].split('/')
26252+ const orgId = parts.slice(-3)[0]
26253+ const repoId = parts.slice(-2)[0]
26254+ const buildId = parts.slice(-1)[0]
26255+ core.debug(`org: ${orgId}`)
26256+ core.debug(`repo: ${repoId}`)
26257+ core.debug(`build: ${buildId}`)
26258+ // Get the URLs
26259+ const artifacts_url = 'https://circleci.com/api/v2/project/gh/' + orgId + '/' + repoId + '/' + buildId + '/artifacts'
26260+ core.debug(`Fetching JSON: ${artifacts_url}`)
26261+ // e.g., https://circleci.com/api/v2/project/gh/larsoner/circleci-artifacts-redirector-action/94/artifacts
26262+ const response = await fetch(artifacts_url)
26263+ const artifacts = await response.json()
26264+ core.debug('Artifacts JSON:')
26265+ core.debug(artifacts)
26266+ // e.g., {"next_page_token":null,"items":[{"path":"test_artifacts/root_artifact.md","node_index":0,"url":"https://output.circle-artifacts.com/output/job/6fdfd148-31da-4a30-8e89-a20595696ca5/artifacts/0/test_artifacts/root_artifact.md"}]}
26267+ const url = artifacts.items[0].url.split('/artifacts/')[0] + '/artifacts/' + path
26268+ core.debug(`Linking to: ${url}`)
2620326269 core.debug((new Date()).toTimeString())
26204- core.setOutput("url", url);
26270+ core.setOutput("url", url)
2620526271 const client = new github.GitHub(token)
2620626272 var description = '';
2620726273 if (payload.state === 'pending') {
@@ -26522,7 +26588,7 @@ var isPlainObject = __webpack_require__(553);
2652226588var nodeFetch = _interopDefault(__webpack_require__(366));
2652326589var requestError = __webpack_require__(38);
2652426590
26525- const VERSION = "5.6.1 ";
26591+ const VERSION = "5.6.3 ";
2652626592
2652726593function getBufferResponse(response) {
2652826594 return response.arrayBuffer();
0 commit comments