@@ -7217,7 +7217,7 @@ Object.defineProperty(Response.prototype, Symbol.toStringTag, {
7217
7217
});
7218
7218
7219
7219
const INTERNALS$2 = Symbol('Request internals');
7220
- const URL = whatwgUrl.URL;
7220
+ const URL = Url.URL || whatwgUrl.URL;
7221
7221
7222
7222
// fix an issue where "format", "parse" aren't a named export for node <10
7223
7223
const parse_url = Url.parse;
@@ -7480,9 +7480,17 @@ AbortError.prototype = Object.create(Error.prototype);
7480
7480
AbortError.prototype.constructor = AbortError;
7481
7481
AbortError.prototype.name = 'AbortError';
7482
7482
7483
+ const URL$1 = Url.URL || whatwgUrl.URL;
7484
+
7483
7485
// fix an issue where "PassThrough", "resolve" aren't a named export for node <10
7484
7486
const 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
+ };
7486
7494
7487
7495
/**
7488
7496
* Fetch function
@@ -7570,7 +7578,19 @@ function fetch(url, opts) {
7570
7578
const location = headers.get('Location');
7571
7579
7572
7580
// 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
+ }
7574
7594
7575
7595
// HTTP fetch step 5.5
7576
7596
switch (request.redirect) {
@@ -7618,6 +7638,12 @@ function fetch(url, opts) {
7618
7638
size: request.size
7619
7639
};
7620
7640
7641
+ if (!isDomainOrSubdomain(request.url, locationURL)) {
7642
+ for (const name of ['authorization', 'www-authenticate', 'cookie', 'cookie2']) {
7643
+ requestOpts.headers.delete(name);
7644
+ }
7645
+ }
7646
+
7621
7647
// HTTP-redirect fetch step 9
7622
7648
if (res.statusCode !== 303 && request.body && getTotalBytes(request) === null) {
7623
7649
reject(new FetchError('Cannot follow redirect with body being a readable stream', 'unsupported-redirect'));
@@ -22576,9 +22602,25 @@ function sync (path, options) {
22576
22602
// ignored, since we can never get coverage for them.
22577
22603
// grab a reference to node's real process object right away
22578
22604
var 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
+
22579
22618
// 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
+ }
22582
22624
} else {
22583
22625
var assert = __webpack_require__(357)
22584
22626
var signals = __webpack_require__(187)
@@ -22609,8 +22651,9 @@ if (typeof process !== 'object' || !process) {
22609
22651
}
22610
22652
22611
22653
module.exports = function (cb, opts) {
22612
- if (global.process !== process) {
22613
- return
22654
+ /* istanbul ignore if */
22655
+ if (!processOk(global.process)) {
22656
+ return function () {}
22614
22657
}
22615
22658
assert.equal(typeof cb, 'function', 'a callback must be provided for exit handler')
22616
22659
@@ -22636,7 +22679,7 @@ if (typeof process !== 'object' || !process) {
22636
22679
}
22637
22680
22638
22681
var unload = function unload () {
22639
- if (!loaded || global.process !== process ) {
22682
+ if (!loaded || !processOk( global.process) ) {
22640
22683
return
22641
22684
}
22642
22685
loaded = false
@@ -22653,6 +22696,7 @@ if (typeof process !== 'object' || !process) {
22653
22696
module.exports.unload = unload
22654
22697
22655
22698
var emit = function emit (event, code, signal) {
22699
+ /* istanbul ignore if */
22656
22700
if (emitter.emitted[event]) {
22657
22701
return
22658
22702
}
@@ -22664,7 +22708,8 @@ if (typeof process !== 'object' || !process) {
22664
22708
var sigListeners = {}
22665
22709
signals.forEach(function (sig) {
22666
22710
sigListeners[sig] = function listener () {
22667
- if (process !== global.process) {
22711
+ /* istanbul ignore if */
22712
+ if (!processOk(global.process)) {
22668
22713
return
22669
22714
}
22670
22715
// If there are no other listeners, an exit is coming!
@@ -22683,6 +22728,7 @@ if (typeof process !== 'object' || !process) {
22683
22728
// so use a supported signal instead
22684
22729
sig = 'SIGINT'
22685
22730
}
22731
+ /* istanbul ignore next */
22686
22732
process.kill(process.pid, sig)
22687
22733
}
22688
22734
}
@@ -22695,7 +22741,7 @@ if (typeof process !== 'object' || !process) {
22695
22741
var loaded = false
22696
22742
22697
22743
var load = function load () {
22698
- if (loaded || process !== global.process) {
22744
+ if (loaded || !processOk( global.process) ) {
22699
22745
return
22700
22746
}
22701
22747
loaded = true
@@ -22722,10 +22768,11 @@ if (typeof process !== 'object' || !process) {
22722
22768
22723
22769
var originalProcessReallyExit = process.reallyExit
22724
22770
var processReallyExit = function processReallyExit (code) {
22725
- if (process !== global.process) {
22771
+ /* istanbul ignore if */
22772
+ if (!processOk(global.process)) {
22726
22773
return
22727
22774
}
22728
- process.exitCode = code || 0
22775
+ process.exitCode = code || /* istanbul ignore next */ 0
22729
22776
emit('exit', process.exitCode, null)
22730
22777
/* istanbul ignore next */
22731
22778
emit('afterexit', process.exitCode, null)
@@ -22735,14 +22782,17 @@ if (typeof process !== 'object' || !process) {
22735
22782
22736
22783
var originalProcessEmit = process.emit
22737
22784
var processEmit = function processEmit (ev, arg) {
22738
- if (ev === 'exit' && process === global.process) {
22785
+ if (ev === 'exit' && processOk(global.process)) {
22786
+ /* istanbul ignore else */
22739
22787
if (arg !== undefined) {
22740
22788
process.exitCode = arg
22741
22789
}
22742
22790
var ret = originalProcessEmit.apply(this, arguments)
22791
+ /* istanbul ignore next */
22743
22792
emit('exit', process.exitCode, null)
22744
22793
/* istanbul ignore next */
22745
22794
emit('afterexit', process.exitCode, null)
22795
+ /* istanbul ignore next */
22746
22796
return ret
22747
22797
} else {
22748
22798
return originalProcessEmit.apply(this, arguments)
@@ -26168,8 +26218,12 @@ module.exports = require("zlib");
26168
26218
//
26169
26219
// After changing this file, use `ncc build index.js` to rebuild to dist/
26170
26220
26221
+ // Refs:
26222
+ // https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#status
26223
+
26171
26224
const core = __webpack_require__(996)
26172
26225
const github = __webpack_require__(828)
26226
+ const fetch = __webpack_require__(366);
26173
26227
26174
26228
async function run() {
26175
26229
try {
@@ -26183,25 +26237,37 @@ async function run() {
26183
26237
}
26184
26238
const prepender = x => 'ci/circleci: ' + x
26185
26239
circleciJobs = circleciJobs.split(',').map(prepender)
26186
- core.debug('Considering CircleCI jobs named:')
26187
- core.debug(circleciJobs)
26240
+ core.debug(`Considering CircleCI jobs named: ${circleciJobs}`)
26188
26241
if (circleciJobs.indexOf(payload.context) < 0) {
26189
- core.debug('Ignoring context:')
26190
- core.debug(payload.context)
26242
+ core.debug(`Ignoring context: ${payload.context}`)
26191
26243
return
26192
26244
}
26193
- core.debug('Processing context and state:')
26194
- core.debug(payload.context)
26195
- core.debug(payload.state)
26196
- // Set the new status
26197
26245
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}`)
26203
26269
core.debug((new Date()).toTimeString())
26204
- core.setOutput("url", url);
26270
+ core.setOutput("url", url)
26205
26271
const client = new github.GitHub(token)
26206
26272
var description = '';
26207
26273
if (payload.state === 'pending') {
@@ -26522,7 +26588,7 @@ var isPlainObject = __webpack_require__(553);
26522
26588
var nodeFetch = _interopDefault(__webpack_require__(366));
26523
26589
var requestError = __webpack_require__(38);
26524
26590
26525
- const VERSION = "5.6.1 ";
26591
+ const VERSION = "5.6.3 ";
26526
26592
26527
26593
function getBufferResponse(response) {
26528
26594
return response.arrayBuffer();
0 commit comments