@actions/artifact 1.1.2 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +111 -174
- package/lib/artifact.d.ts +6 -0
- package/lib/artifact.js +23 -0
- package/lib/artifact.js.map +1 -0
- package/lib/generated/google/protobuf/timestamp.d.ts +145 -0
- package/lib/generated/google/protobuf/timestamp.js +136 -0
- package/lib/generated/google/protobuf/timestamp.js.map +1 -0
- package/lib/generated/google/protobuf/wrappers.d.ts +307 -0
- package/lib/generated/google/protobuf/wrappers.js +609 -0
- package/lib/generated/google/protobuf/wrappers.js.map +1 -0
- package/lib/generated/index.d.ts +4 -0
- package/lib/generated/index.js +21 -0
- package/lib/generated/index.js.map +1 -0
- package/lib/generated/results/api/v1/artifact.d.ts +286 -0
- package/lib/generated/results/api/v1/artifact.js +588 -0
- package/lib/generated/results/api/v1/artifact.js.map +1 -0
- package/lib/generated/results/api/v1/artifact.twirp.d.ts +43 -0
- package/lib/generated/results/api/v1/artifact.twirp.js +416 -0
- package/lib/generated/results/api/v1/artifact.twirp.js.map +1 -0
- package/lib/internal/client.d.ts +61 -0
- package/lib/internal/client.js +121 -0
- package/lib/internal/client.js.map +1 -0
- package/lib/internal/download/download-artifact.d.ts +3 -0
- package/lib/internal/download/download-artifact.js +168 -0
- package/lib/internal/download/download-artifact.js.map +1 -0
- package/lib/internal/find/get-artifact.d.ts +3 -0
- package/lib/internal/find/get-artifact.js +118 -0
- package/lib/internal/find/get-artifact.js.map +1 -0
- package/lib/internal/find/list-artifacts.d.ts +3 -0
- package/lib/internal/find/list-artifacts.js +139 -0
- package/lib/internal/find/list-artifacts.js.map +1 -0
- package/lib/internal/find/retry-options.d.ts +7 -0
- package/lib/internal/find/retry-options.js +50 -0
- package/lib/internal/find/retry-options.js.map +1 -0
- package/lib/internal/shared/artifact-twirp-client.d.ts +6 -0
- package/lib/internal/shared/artifact-twirp-client.js +153 -0
- package/lib/internal/shared/artifact-twirp-client.js.map +1 -0
- package/lib/internal/shared/config.d.ts +6 -0
- package/lib/internal/shared/config.js +55 -0
- package/lib/internal/shared/config.js.map +1 -0
- package/lib/internal/shared/errors.d.ts +22 -0
- package/lib/internal/shared/errors.js +70 -0
- package/lib/internal/shared/errors.js.map +1 -0
- package/lib/internal/shared/interfaces.d.ts +136 -0
- package/lib/internal/{contracts.js → shared/interfaces.js} +1 -1
- package/lib/internal/shared/interfaces.js.map +1 -0
- package/lib/internal/shared/user-agent.d.ts +4 -0
- package/lib/internal/shared/user-agent.js +13 -0
- package/lib/internal/shared/user-agent.js.map +1 -0
- package/lib/internal/shared/util.d.ts +5 -0
- package/lib/internal/shared/util.js +81 -0
- package/lib/internal/shared/util.js.map +1 -0
- package/lib/internal/upload/blob-upload.d.ts +12 -0
- package/lib/internal/upload/blob-upload.js +87 -0
- package/lib/internal/upload/blob-upload.js.map +1 -0
- package/lib/internal/upload/path-and-artifact-name-validation.d.ts +8 -0
- package/lib/internal/{path-and-artifact-name-validation.js → upload/path-and-artifact-name-validation.js} +11 -11
- package/lib/internal/upload/path-and-artifact-name-validation.js.map +1 -0
- package/lib/internal/upload/retention.d.ts +2 -0
- package/lib/internal/upload/retention.js +54 -0
- package/lib/internal/upload/retention.js.map +1 -0
- package/lib/internal/upload/upload-artifact.d.ts +2 -0
- package/lib/internal/upload/upload-artifact.js +103 -0
- package/lib/internal/upload/upload-artifact.js.map +1 -0
- package/lib/internal/upload/upload-zip-specification.d.ts +21 -0
- package/lib/internal/{upload-specification.js → upload/upload-zip-specification.js} +44 -36
- package/lib/internal/upload/upload-zip-specification.js.map +1 -0
- package/lib/internal/upload/zip.d.ts +9 -0
- package/lib/internal/upload/zip.js +113 -0
- package/lib/internal/upload/zip.js.map +1 -0
- package/package.json +25 -11
- package/lib/artifact-client.d.ts +0 -10
- package/lib/artifact-client.js +0 -12
- package/lib/artifact-client.js.map +0 -1
- package/lib/internal/artifact-client.d.ts +0 -41
- package/lib/internal/artifact-client.js +0 -182
- package/lib/internal/artifact-client.js.map +0 -1
- package/lib/internal/config-variables.d.ts +0 -12
- package/lib/internal/config-variables.js +0 -77
- package/lib/internal/config-variables.js.map +0 -1
- package/lib/internal/contracts.d.ts +0 -67
- package/lib/internal/contracts.js.map +0 -1
- package/lib/internal/crc64.d.ts +0 -21
- package/lib/internal/crc64.js +0 -303
- package/lib/internal/crc64.js.map +0 -1
- package/lib/internal/download-http-client.d.ts +0 -39
- package/lib/internal/download-http-client.js +0 -296
- package/lib/internal/download-http-client.js.map +0 -1
- package/lib/internal/download-options.d.ts +0 -7
- package/lib/internal/download-options.js +0 -3
- package/lib/internal/download-options.js.map +0 -1
- package/lib/internal/download-response.d.ts +0 -10
- package/lib/internal/download-response.js +0 -3
- package/lib/internal/download-response.js.map +0 -1
- package/lib/internal/download-specification.d.ts +0 -19
- package/lib/internal/download-specification.js +0 -78
- package/lib/internal/download-specification.js.map +0 -1
- package/lib/internal/http-manager.d.ts +0 -12
- package/lib/internal/http-manager.js +0 -32
- package/lib/internal/http-manager.js.map +0 -1
- package/lib/internal/path-and-artifact-name-validation.d.ts +0 -8
- package/lib/internal/path-and-artifact-name-validation.js.map +0 -1
- package/lib/internal/requestUtils.d.ts +0 -3
- package/lib/internal/requestUtils.js +0 -92
- package/lib/internal/requestUtils.js.map +0 -1
- package/lib/internal/status-reporter.d.ts +0 -21
- package/lib/internal/status-reporter.js +0 -52
- package/lib/internal/status-reporter.js.map +0 -1
- package/lib/internal/upload-gzip.d.ts +0 -14
- package/lib/internal/upload-gzip.js +0 -147
- package/lib/internal/upload-gzip.js.map +0 -1
- package/lib/internal/upload-http-client.d.ts +0 -48
- package/lib/internal/upload-http-client.js +0 -415
- package/lib/internal/upload-http-client.js.map +0 -1
- package/lib/internal/upload-options.d.ts +0 -34
- package/lib/internal/upload-options.js +0 -3
- package/lib/internal/upload-options.js.map +0 -1
- package/lib/internal/upload-response.d.ts +0 -19
- package/lib/internal/upload-response.js +0 -3
- package/lib/internal/upload-response.js.map +0 -1
- package/lib/internal/upload-specification.d.ts +0 -11
- package/lib/internal/upload-specification.js.map +0 -1
- package/lib/internal/utils.d.ts +0 -71
- package/lib/internal/utils.js +0 -292
- package/lib/internal/utils.js.map +0 -1
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
+
var t = {};
|
|
13
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
+
t[p] = s[p];
|
|
15
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
+
t[p[i]] = s[p[i]];
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.DefaultArtifactClient = void 0;
|
|
24
|
+
const core_1 = require("@actions/core");
|
|
25
|
+
const config_1 = require("./shared/config");
|
|
26
|
+
const upload_artifact_1 = require("./upload/upload-artifact");
|
|
27
|
+
const download_artifact_1 = require("./download/download-artifact");
|
|
28
|
+
const get_artifact_1 = require("./find/get-artifact");
|
|
29
|
+
const list_artifacts_1 = require("./find/list-artifacts");
|
|
30
|
+
const errors_1 = require("./shared/errors");
|
|
31
|
+
/**
|
|
32
|
+
* The default artifact client that is used by the artifact action(s).
|
|
33
|
+
*/
|
|
34
|
+
class DefaultArtifactClient {
|
|
35
|
+
uploadArtifact(name, files, rootDirectory, options) {
|
|
36
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
try {
|
|
38
|
+
if ((0, config_1.isGhes)()) {
|
|
39
|
+
throw new errors_1.GHESNotSupportedError();
|
|
40
|
+
}
|
|
41
|
+
return (0, upload_artifact_1.uploadArtifact)(name, files, rootDirectory, options);
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
(0, core_1.warning)(`Artifact upload failed with error: ${error}.
|
|
45
|
+
|
|
46
|
+
Errors can be temporary, so please try again and optionally run the action with debug mode enabled for more information.
|
|
47
|
+
|
|
48
|
+
If the error persists, please check whether Actions is operating normally at [https://githubstatus.com](https://www.githubstatus.com).`);
|
|
49
|
+
throw error;
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
downloadArtifact(artifactId, options) {
|
|
54
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
try {
|
|
56
|
+
if ((0, config_1.isGhes)()) {
|
|
57
|
+
throw new errors_1.GHESNotSupportedError();
|
|
58
|
+
}
|
|
59
|
+
if (options === null || options === void 0 ? void 0 : options.findBy) {
|
|
60
|
+
const { findBy: { repositoryOwner, repositoryName, token } } = options, downloadOptions = __rest(options, ["findBy"]);
|
|
61
|
+
return (0, download_artifact_1.downloadArtifactPublic)(artifactId, repositoryOwner, repositoryName, token, downloadOptions);
|
|
62
|
+
}
|
|
63
|
+
return (0, download_artifact_1.downloadArtifactInternal)(artifactId, options);
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
(0, core_1.warning)(`Download Artifact failed with error: ${error}.
|
|
67
|
+
|
|
68
|
+
Errors can be temporary, so please try again and optionally run the action with debug mode enabled for more information.
|
|
69
|
+
|
|
70
|
+
If the error persists, please check whether Actions and API requests are operating normally at [https://githubstatus.com](https://www.githubstatus.com).`);
|
|
71
|
+
throw error;
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
listArtifacts(options) {
|
|
76
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
77
|
+
try {
|
|
78
|
+
if ((0, config_1.isGhes)()) {
|
|
79
|
+
throw new errors_1.GHESNotSupportedError();
|
|
80
|
+
}
|
|
81
|
+
if (options === null || options === void 0 ? void 0 : options.findBy) {
|
|
82
|
+
const { findBy: { workflowRunId, repositoryOwner, repositoryName, token } } = options;
|
|
83
|
+
return (0, list_artifacts_1.listArtifactsPublic)(workflowRunId, repositoryOwner, repositoryName, token, options === null || options === void 0 ? void 0 : options.latest);
|
|
84
|
+
}
|
|
85
|
+
return (0, list_artifacts_1.listArtifactsInternal)(options === null || options === void 0 ? void 0 : options.latest);
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
(0, core_1.warning)(`Listing Artifacts failed with error: ${error}.
|
|
89
|
+
|
|
90
|
+
Errors can be temporary, so please try again and optionally run the action with debug mode enabled for more information.
|
|
91
|
+
|
|
92
|
+
If the error persists, please check whether Actions and API requests are operating normally at [https://githubstatus.com](https://www.githubstatus.com).`);
|
|
93
|
+
throw error;
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
getArtifact(artifactName, options) {
|
|
98
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
99
|
+
try {
|
|
100
|
+
if ((0, config_1.isGhes)()) {
|
|
101
|
+
throw new errors_1.GHESNotSupportedError();
|
|
102
|
+
}
|
|
103
|
+
if (options === null || options === void 0 ? void 0 : options.findBy) {
|
|
104
|
+
const { findBy: { workflowRunId, repositoryOwner, repositoryName, token } } = options;
|
|
105
|
+
return (0, get_artifact_1.getArtifactPublic)(artifactName, workflowRunId, repositoryOwner, repositoryName, token);
|
|
106
|
+
}
|
|
107
|
+
return (0, get_artifact_1.getArtifactInternal)(artifactName);
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
(0, core_1.warning)(`Get Artifact failed with error: ${error}.
|
|
111
|
+
|
|
112
|
+
Errors can be temporary, so please try again and optionally run the action with debug mode enabled for more information.
|
|
113
|
+
|
|
114
|
+
If the error persists, please check whether Actions and API requests are operating normally at [https://githubstatus.com](https://www.githubstatus.com).`);
|
|
115
|
+
throw error;
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
exports.DefaultArtifactClient = DefaultArtifactClient;
|
|
121
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/internal/client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA,wCAAqC;AACrC,4CAAsC;AAWtC,8DAAuD;AACvD,oEAGqC;AACrC,sDAA0E;AAC1E,0DAAgF;AAChF,4CAAqD;AAsErD;;GAEG;AACH,MAAa,qBAAqB;IAC1B,cAAc,CAClB,IAAY,EACZ,KAAe,EACf,aAAqB,EACrB,OAA+B;;YAE/B,IAAI;gBACF,IAAI,IAAA,eAAM,GAAE,EAAE;oBACZ,MAAM,IAAI,8BAAqB,EAAE,CAAA;iBAClC;gBAED,OAAO,IAAA,gCAAc,EAAC,IAAI,EAAE,KAAK,EAAE,aAAa,EAAE,OAAO,CAAC,CAAA;aAC3D;YAAC,OAAO,KAAK,EAAE;gBACd,IAAA,cAAO,EACL,sCAAsC,KAAK;;;;uIAIoF,CAChI,CAAA;gBAED,MAAM,KAAK,CAAA;aACZ;QACH,CAAC;KAAA;IAEK,gBAAgB,CACpB,UAAkB,EAClB,OAA+C;;YAE/C,IAAI;gBACF,IAAI,IAAA,eAAM,GAAE,EAAE;oBACZ,MAAM,IAAI,8BAAq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;gBACF,IAAI,IAAA,eAAM,GAAE,EAAE;oBACZ,MAAM,IAAI,8BAAqB,EAAE,CAAA;iBAClC;gBAED,IAAI,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAM,EAAE;oBACnB,MAAM,EACJ,MAAM,EAAE,EAAC,aAAa,EAAE,eAAe,EAAE,cAAc,EAAE,KAAK,EAAC,EAChE,GAAG,OAAO,CAAA;oBAEX,OAAO,IAAA,gCAAiB,EACtB,YAAY,EACZ,aAAa,EACb,eAAe,EACf,cAAc,EACd,KAAK,CACN,CAAA;iBACF;gBAED,OAAO,IAAA,kCAAmB,EAAC,YAAY,CAAC,CAAA;aACzC;YAAC,OAAO,KAAc,EAAE;gBACvB,IAAA,cAAO,EACL,mCAAmC,KAAK;;;;yJAIyG,CAClJ,CAAA;gBACD,MAAM,KAAK,CAAA;aACZ;QACH,CAAC;KAAA;CACF;AAvID,sDAuIC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { DownloadArtifactOptions, DownloadArtifactResponse } from '../shared/interfaces';
|
|
2
|
+
export declare function downloadArtifactPublic(artifactId: number, repositoryOwner: string, repositoryName: string, token: string, options?: DownloadArtifactOptions): Promise<DownloadArtifactResponse>;
|
|
3
|
+
export declare function downloadArtifactInternal(artifactId: number, options?: DownloadArtifactOptions): Promise<DownloadArtifactResponse>;
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
+
};
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
exports.downloadArtifactInternal = exports.downloadArtifactPublic = void 0;
|
|
39
|
+
const promises_1 = __importDefault(require("fs/promises"));
|
|
40
|
+
const github = __importStar(require("@actions/github"));
|
|
41
|
+
const core = __importStar(require("@actions/core"));
|
|
42
|
+
const httpClient = __importStar(require("@actions/http-client"));
|
|
43
|
+
const unzip_stream_1 = __importDefault(require("unzip-stream"));
|
|
44
|
+
const user_agent_1 = require("../shared/user-agent");
|
|
45
|
+
const config_1 = require("../shared/config");
|
|
46
|
+
const artifact_twirp_client_1 = require("../shared/artifact-twirp-client");
|
|
47
|
+
const generated_1 = require("../../generated");
|
|
48
|
+
const util_1 = require("../shared/util");
|
|
49
|
+
const errors_1 = require("../shared/errors");
|
|
50
|
+
const scrubQueryParameters = (url) => {
|
|
51
|
+
const parsed = new URL(url);
|
|
52
|
+
parsed.search = '';
|
|
53
|
+
return parsed.toString();
|
|
54
|
+
};
|
|
55
|
+
function exists(path) {
|
|
56
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
try {
|
|
58
|
+
yield promises_1.default.access(path);
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
if (error.code === 'ENOENT') {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
throw error;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
function streamExtract(url, directory) {
|
|
72
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
73
|
+
const client = new httpClient.HttpClient((0, user_agent_1.getUserAgentString)());
|
|
74
|
+
const response = yield client.get(url);
|
|
75
|
+
if (response.message.statusCode !== 200) {
|
|
76
|
+
throw new Error(`Unexpected HTTP response from blob storage: ${response.message.statusCode} ${response.message.statusMessage}`);
|
|
77
|
+
}
|
|
78
|
+
return new Promise((resolve, reject) => {
|
|
79
|
+
response.message
|
|
80
|
+
.pipe(unzip_stream_1.default.Extract({ path: directory }))
|
|
81
|
+
.on('close', resolve)
|
|
82
|
+
.on('error', reject);
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
function downloadArtifactPublic(artifactId, repositoryOwner, repositoryName, token, options) {
|
|
87
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
88
|
+
const downloadPath = yield resolveOrCreateDirectory(options === null || options === void 0 ? void 0 : options.path);
|
|
89
|
+
const api = github.getOctokit(token);
|
|
90
|
+
core.info(`Downloading artifact '${artifactId}' from '${repositoryOwner}/${repositoryName}'`);
|
|
91
|
+
const { headers, status } = yield api.rest.actions.downloadArtifact({
|
|
92
|
+
owner: repositoryOwner,
|
|
93
|
+
repo: repositoryName,
|
|
94
|
+
artifact_id: artifactId,
|
|
95
|
+
archive_format: 'zip',
|
|
96
|
+
request: {
|
|
97
|
+
redirect: 'manual'
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
if (status !== 302) {
|
|
101
|
+
throw new Error(`Unable to download artifact. Unexpected status: ${status}`);
|
|
102
|
+
}
|
|
103
|
+
const { location } = headers;
|
|
104
|
+
if (!location) {
|
|
105
|
+
throw new Error(`Unable to redirect to artifact download url`);
|
|
106
|
+
}
|
|
107
|
+
core.info(`Redirecting to blob download url: ${scrubQueryParameters(location)}`);
|
|
108
|
+
try {
|
|
109
|
+
core.info(`Starting download of artifact to: ${downloadPath}`);
|
|
110
|
+
yield streamExtract(location, downloadPath);
|
|
111
|
+
core.info(`Artifact download completed successfully.`);
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
throw new Error(`Unable to download and extract artifact: ${error.message}`);
|
|
115
|
+
}
|
|
116
|
+
return { downloadPath };
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
exports.downloadArtifactPublic = downloadArtifactPublic;
|
|
120
|
+
function downloadArtifactInternal(artifactId, options) {
|
|
121
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
122
|
+
const downloadPath = yield resolveOrCreateDirectory(options === null || options === void 0 ? void 0 : options.path);
|
|
123
|
+
const artifactClient = (0, artifact_twirp_client_1.internalArtifactTwirpClient)();
|
|
124
|
+
const { workflowRunBackendId, workflowJobRunBackendId } = (0, util_1.getBackendIdsFromToken)();
|
|
125
|
+
const listReq = {
|
|
126
|
+
workflowRunBackendId,
|
|
127
|
+
workflowJobRunBackendId,
|
|
128
|
+
idFilter: generated_1.Int64Value.create({ value: artifactId.toString() })
|
|
129
|
+
};
|
|
130
|
+
const { artifacts } = yield artifactClient.ListArtifacts(listReq);
|
|
131
|
+
if (artifacts.length === 0) {
|
|
132
|
+
throw new errors_1.ArtifactNotFoundError(`No artifacts found for ID: ${artifactId}\nAre you trying to download from a different run? Try specifying a github-token with \`actions:read\` scope.`);
|
|
133
|
+
}
|
|
134
|
+
if (artifacts.length > 1) {
|
|
135
|
+
core.warning('Multiple artifacts found, defaulting to first.');
|
|
136
|
+
}
|
|
137
|
+
const signedReq = {
|
|
138
|
+
workflowRunBackendId: artifacts[0].workflowRunBackendId,
|
|
139
|
+
workflowJobRunBackendId: artifacts[0].workflowJobRunBackendId,
|
|
140
|
+
name: artifacts[0].name
|
|
141
|
+
};
|
|
142
|
+
const { signedUrl } = yield artifactClient.GetSignedArtifactURL(signedReq);
|
|
143
|
+
core.info(`Redirecting to blob download url: ${scrubQueryParameters(signedUrl)}`);
|
|
144
|
+
try {
|
|
145
|
+
core.info(`Starting download of artifact to: ${downloadPath}`);
|
|
146
|
+
yield streamExtract(signedUrl, downloadPath);
|
|
147
|
+
core.info(`Artifact download completed successfully.`);
|
|
148
|
+
}
|
|
149
|
+
catch (error) {
|
|
150
|
+
throw new Error(`Unable to download and extract artifact: ${error.message}`);
|
|
151
|
+
}
|
|
152
|
+
return { downloadPath };
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
exports.downloadArtifactInternal = downloadArtifactInternal;
|
|
156
|
+
function resolveOrCreateDirectory(downloadPath = (0, config_1.getGitHubWorkspaceDir)()) {
|
|
157
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
158
|
+
if (!(yield exists(downloadPath))) {
|
|
159
|
+
core.debug(`Artifact destination folder does not exist, creating: ${downloadPath}`);
|
|
160
|
+
yield promises_1.default.mkdir(downloadPath, { recursive: true });
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
core.debug(`Artifact destination folder already exists: ${downloadPath}`);
|
|
164
|
+
}
|
|
165
|
+
return downloadPath;
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
//# sourceMappingURL=download-artifact.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"download-artifact.js","sourceRoot":"","sources":["../../../src/internal/download/download-artifact.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2DAA4B;AAC5B,wDAAyC;AACzC,oDAAqC;AACrC,iEAAkD;AAClD,gEAAgC;AAKhC,qDAAuD;AACvD,6CAAsD;AACtD,2EAA2E;AAC3E,+CAIwB;AACxB,yCAAqD;AACrD,6CAAsD;AAEtD,MAAM,oBAAoB,GAAG,CAAC,GAAW,EAAU,EAAE;IACnD,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAA;IAC3B,MAAM,CAAC,MAAM,GAAG,EAAE,CAAA;IAClB,OAAO,MAAM,CAAC,QAAQ,EAAE,CAAA;AAC1B,CAAC,CAAA;AAED,SAAe,MAAM,CAAC,IAAY;;QAChC,IAAI;YACF,MAAM,kBAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;YACrB,OAAO,IAAI,CAAA;SACZ;QAAC,OAAO,KAAK,EAAE;YACd,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE;gBAC3B,OAAO,KAAK,CAAA;aACb;iBAAM;gBACL,MAAM,KAAK,CAAA;aACZ;SACF;IACH,CAAC;CAAA;AAED,SAAe,aAAa,CAAC,GAAW,EAAE,SAAiB;;QACzD,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,UAAU,CAAC,IAAA,+BAAkB,GAAE,CAAC,CAAA;QAC9D,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QAEtC,IAAI,QAAQ,CAAC,OAAO,CAAC,UAAU,KAAK,GAAG,EAAE;YACvC,MAAM,IAAI,KAAK,CACb,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ublic(artifactName: string, workflowRunId: number, repositoryOwner: string, repositoryName: string, token: string): Promise<GetArtifactResponse>;
|
|
3
|
+
export declare function getArtifactInternal(artifactName: string): Promise<GetArtifactResponse>;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
exports.getArtifactInternal = exports.getArtifactPublic = void 0;
|
|
36
|
+
const github_1 = require("@actions/github");
|
|
37
|
+
const plugin_retry_1 = require("@octokit/plugin-retry");
|
|
38
|
+
const core = __importStar(require("@actions/core"));
|
|
39
|
+
const utils_1 = require("@actions/github/lib/utils");
|
|
40
|
+
const retry_options_1 = require("./retry-options");
|
|
41
|
+
const plugin_request_log_1 = require("@octokit/plugin-request-log");
|
|
42
|
+
const util_1 = require("../shared/util");
|
|
43
|
+
const user_agent_1 = require("../shared/user-agent");
|
|
44
|
+
const artifact_twirp_client_1 = require("../shared/artifact-twirp-client");
|
|
45
|
+
const generated_1 = require("../../generated");
|
|
46
|
+
const errors_1 = require("../shared/errors");
|
|
47
|
+
function getArtifactPublic(artifactName, workflowRunId, repositoryOwner, repositoryName, token) {
|
|
48
|
+
var _a;
|
|
49
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
const [retryOpts, requestOpts] = (0, retry_options_1.getRetryOptions)(utils_1.defaults);
|
|
51
|
+
const opts = {
|
|
52
|
+
log: undefined,
|
|
53
|
+
userAgent: (0, user_agent_1.getUserAgentString)(),
|
|
54
|
+
previews: undefined,
|
|
55
|
+
retry: retryOpts,
|
|
56
|
+
request: requestOpts
|
|
57
|
+
};
|
|
58
|
+
const github = (0, github_1.getOctokit)(token, opts, plugin_retry_1.retry, plugin_request_log_1.requestLog);
|
|
59
|
+
const getArtifactResp = yield github.request('GET /repos/{owner}/{repo}/actions/runs/{run_id}/artifacts{?name}', {
|
|
60
|
+
owner: repositoryOwner,
|
|
61
|
+
repo: repositoryName,
|
|
62
|
+
run_id: workflowRunId,
|
|
63
|
+
name: artifactName
|
|
64
|
+
});
|
|
65
|
+
if (getArtifactResp.status !== 200) {
|
|
66
|
+
throw new errors_1.InvalidResponseError(`Invalid response from GitHub API: ${getArtifactResp.status} (${(_a = getArtifactResp === null || getArtifactResp === void 0 ? void 0 : getArtifactResp.headers) === null || _a === void 0 ? void 0 : _a['x-github-request-id']})`);
|
|
67
|
+
}
|
|
68
|
+
if (getArtifactResp.data.artifacts.length === 0) {
|
|
69
|
+
throw new errors_1.ArtifactNotFoundError(`Artifact not found for name: ${artifactName}`);
|
|
70
|
+
}
|
|
71
|
+
let artifact = getArtifactResp.data.artifacts[0];
|
|
72
|
+
if (getArtifactResp.data.artifacts.length > 1) {
|
|
73
|
+
artifact = getArtifactResp.data.artifacts.sort((a, b) => b.id - a.id)[0];
|
|
74
|
+
core.debug(`More than one artifact found for a single name, returning newest (id: ${artifact.id})`);
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
artifact: {
|
|
78
|
+
name: artifact.name,
|
|
79
|
+
id: artifact.id,
|
|
80
|
+
size: artifact.size_in_bytes,
|
|
81
|
+
createdAt: artifact.created_at ? new Date(artifact.created_at) : undefined
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
exports.getArtifactPublic = getArtifactPublic;
|
|
87
|
+
function getArtifactInternal(artifactName) {
|
|
88
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
89
|
+
const artifactClient = (0, artifact_twirp_client_1.internalArtifactTwirpClient)();
|
|
90
|
+
const { workflowRunBackendId, workflowJobRunBackendId } = (0, util_1.getBackendIdsFromToken)();
|
|
91
|
+
const req = {
|
|
92
|
+
workflowRunBackendId,
|
|
93
|
+
workflowJobRunBackendId,
|
|
94
|
+
nameFilter: generated_1.StringValue.create({ value: artifactName })
|
|
95
|
+
};
|
|
96
|
+
const res = yield artifactClient.ListArtifacts(req);
|
|
97
|
+
if (res.artifacts.length === 0) {
|
|
98
|
+
throw new errors_1.ArtifactNotFoundError(`Artifact not found for name: ${artifactName}`);
|
|
99
|
+
}
|
|
100
|
+
let artifact = res.artifacts[0];
|
|
101
|
+
if (res.artifacts.length > 1) {
|
|
102
|
+
artifact = res.artifacts.sort((a, b) => Number(b.databaseId) - Number(a.databaseId))[0];
|
|
103
|
+
core.debug(`More than one artifact found for a single name, returning newest (id: ${artifact.databaseId})`);
|
|
104
|
+
}
|
|
105
|
+
return {
|
|
106
|
+
artifact: {
|
|
107
|
+
name: artifact.name,
|
|
108
|
+
id: Number(artifact.databaseId),
|
|
109
|
+
size: Number(artifact.size),
|
|
110
|
+
createdAt: artifact.createdAt
|
|
111
|
+
? generated_1.Timestamp.toDate(artifact.createdAt)
|
|
112
|
+
: undefined
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
exports.getArtifactInternal = getArtifactInternal;
|
|
118
|
+
//# sourceMappingURL=get-artifact.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-artifact.js","sourceRoot":"","sources":["../../../src/internal/find/get-artifact.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAA0C;AAC1C,wDAA2C;AAC3C,oDAAqC;AAErC,qDAA0E;AAC1E,mDAA+C;AAC/C,oEAAsD;AAEtD,yCAAqD;AACrD,qDAAuD;AACvD,2EAA2E;AAC3E,+CAA4E;AAC5E,6CAA4E;AAE5E,SAAsB,iBAAiB,CACrC,YAAoB,EACpB,aAAqB,EACrB,eAAuB,EACvB,cAAsB,EACtB,KAAa;;;QAEb,MAAM,CAAC,SAAS,EAAE,WAAW,CAAC,GAAG,IAAA,+BAAe,EAAC,gBAAoB,CAAC,CAAA;QAEtE,MAAM,IAAI,GAAmB;YAC3B,GAAG,EAAE,SAAS;YACd,SAAS,EAAE,IAAA,+BAAkB,GAAE;YAC/B,QAAQ,EAAE,SAAS;YACnB,KAAK,EAAE,SAAS;YAChB,OAAO,EAAE,WAA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,CAAC,IAAI,CAAC;gBAC3B,SAAS,EAAE,QAAQ,CAAC,SAAS;oBAC3B,CAAC,CAAC,qBAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC;oBACtC,CAAC,CAAC,SAAS;aACd;SACF,CAAA;IACH,CAAC;CAAA;AA3CD,kDA2CC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ListArtifactsResponse } from '../shared/interfaces';
|
|
2
|
+
export declare function listArtifactsPublic(workflowRunId: number, repositoryOwner: string, repositoryName: string, token: string, latest?: boolean): Promise<ListArtifactsResponse>;
|
|
3
|
+
export declare function listArtifactsInternal(latest?: boolean): Promise<ListArtifactsResponse>;
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.listArtifactsInternal = exports.listArtifactsPublic = void 0;
|
|
13
|
+
const core_1 = require("@actions/core");
|
|
14
|
+
const github_1 = require("@actions/github");
|
|
15
|
+
const user_agent_1 = require("../shared/user-agent");
|
|
16
|
+
const retry_options_1 = require("./retry-options");
|
|
17
|
+
const utils_1 = require("@actions/github/lib/utils");
|
|
18
|
+
const plugin_request_log_1 = require("@octokit/plugin-request-log");
|
|
19
|
+
const plugin_retry_1 = require("@octokit/plugin-retry");
|
|
20
|
+
const artifact_twirp_client_1 = require("../shared/artifact-twirp-client");
|
|
21
|
+
const util_1 = require("../shared/util");
|
|
22
|
+
const generated_1 = require("../../generated");
|
|
23
|
+
// Limiting to 1000 for perf reasons
|
|
24
|
+
const maximumArtifactCount = 1000;
|
|
25
|
+
const paginationCount = 100;
|
|
26
|
+
const maxNumberOfPages = maximumArtifactCount / paginationCount;
|
|
27
|
+
function listArtifactsPublic(workflowRunId, repositoryOwner, repositoryName, token, latest = false) {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
(0, core_1.info)(`Fetching artifact list for workflow run ${workflowRunId} in repository ${repositoryOwner}/${repositoryName}`);
|
|
30
|
+
let artifacts = [];
|
|
31
|
+
const [retryOpts, requestOpts] = (0, retry_options_1.getRetryOptions)(utils_1.defaults);
|
|
32
|
+
const opts = {
|
|
33
|
+
log: undefined,
|
|
34
|
+
userAgent: (0, user_agent_1.getUserAgentString)(),
|
|
35
|
+
previews: undefined,
|
|
36
|
+
retry: retryOpts,
|
|
37
|
+
request: requestOpts
|
|
38
|
+
};
|
|
39
|
+
const github = (0, github_1.getOctokit)(token, opts, plugin_retry_1.retry, plugin_request_log_1.requestLog);
|
|
40
|
+
let currentPageNumber = 1;
|
|
41
|
+
const { data: listArtifactResponse } = yield github.rest.actions.listWorkflowRunArtifacts({
|
|
42
|
+
owner: repositoryOwner,
|
|
43
|
+
repo: repositoryName,
|
|
44
|
+
run_id: workflowRunId,
|
|
45
|
+
per_page: paginationCount,
|
|
46
|
+
page: currentPageNumber
|
|
47
|
+
});
|
|
48
|
+
let numberOfPages = Math.ceil(listArtifactResponse.total_count / paginationCount);
|
|
49
|
+
const totalArtifactCount = listArtifactResponse.total_count;
|
|
50
|
+
if (totalArtifactCount > maximumArtifactCount) {
|
|
51
|
+
(0, core_1.warning)(`Workflow run ${workflowRunId} has more than 1000 artifacts. Results will be incomplete as only the first ${maximumArtifactCount} artifacts will be returned`);
|
|
52
|
+
numberOfPages = maxNumberOfPages;
|
|
53
|
+
}
|
|
54
|
+
// Iterate over the first page
|
|
55
|
+
for (const artifact of listArtifactResponse.artifacts) {
|
|
56
|
+
artifacts.push({
|
|
57
|
+
name: artifact.name,
|
|
58
|
+
id: artifact.id,
|
|
59
|
+
size: artifact.size_in_bytes,
|
|
60
|
+
createdAt: artifact.created_at ? new Date(artifact.created_at) : undefined
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
// Iterate over any remaining pages
|
|
64
|
+
for (currentPageNumber; currentPageNumber < numberOfPages; currentPageNumber++) {
|
|
65
|
+
currentPageNumber++;
|
|
66
|
+
(0, core_1.debug)(`Fetching page ${currentPageNumber} of artifact list`);
|
|
67
|
+
const { data: listArtifactResponse } = yield github.rest.actions.listWorkflowRunArtifacts({
|
|
68
|
+
owner: repositoryOwner,
|
|
69
|
+
repo: repositoryName,
|
|
70
|
+
run_id: workflowRunId,
|
|
71
|
+
per_page: paginationCount,
|
|
72
|
+
page: currentPageNumber
|
|
73
|
+
});
|
|
74
|
+
for (const artifact of listArtifactResponse.artifacts) {
|
|
75
|
+
artifacts.push({
|
|
76
|
+
name: artifact.name,
|
|
77
|
+
id: artifact.id,
|
|
78
|
+
size: artifact.size_in_bytes,
|
|
79
|
+
createdAt: artifact.created_at
|
|
80
|
+
? new Date(artifact.created_at)
|
|
81
|
+
: undefined
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (latest) {
|
|
86
|
+
artifacts = filterLatest(artifacts);
|
|
87
|
+
}
|
|
88
|
+
(0, core_1.info)(`Found ${artifacts.length} artifact(s)`);
|
|
89
|
+
return {
|
|
90
|
+
artifacts
|
|
91
|
+
};
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
exports.listArtifactsPublic = listArtifactsPublic;
|
|
95
|
+
function listArtifactsInternal(latest = false) {
|
|
96
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
97
|
+
const artifactClient = (0, artifact_twirp_client_1.internalArtifactTwirpClient)();
|
|
98
|
+
const { workflowRunBackendId, workflowJobRunBackendId } = (0, util_1.getBackendIdsFromToken)();
|
|
99
|
+
const req = {
|
|
100
|
+
workflowRunBackendId,
|
|
101
|
+
workflowJobRunBackendId
|
|
102
|
+
};
|
|
103
|
+
const res = yield artifactClient.ListArtifacts(req);
|
|
104
|
+
let artifacts = res.artifacts.map(artifact => ({
|
|
105
|
+
name: artifact.name,
|
|
106
|
+
id: Number(artifact.databaseId),
|
|
107
|
+
size: Number(artifact.size),
|
|
108
|
+
createdAt: artifact.createdAt
|
|
109
|
+
? generated_1.Timestamp.toDate(artifact.createdAt)
|
|
110
|
+
: undefined
|
|
111
|
+
}));
|
|
112
|
+
if (latest) {
|
|
113
|
+
artifacts = filterLatest(artifacts);
|
|
114
|
+
}
|
|
115
|
+
(0, core_1.info)(`Found ${artifacts.length} artifact(s)`);
|
|
116
|
+
return {
|
|
117
|
+
artifacts
|
|
118
|
+
};
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
exports.listArtifactsInternal = listArtifactsInternal;
|
|
122
|
+
/**
|
|
123
|
+
* Filters a list of artifacts to only include the latest artifact for each name
|
|
124
|
+
* @param artifacts The artifacts to filter
|
|
125
|
+
* @returns The filtered list of artifacts
|
|
126
|
+
*/
|
|
127
|
+
function filterLatest(artifacts) {
|
|
128
|
+
artifacts.sort((a, b) => b.id - a.id);
|
|
129
|
+
const latestArtifacts = [];
|
|
130
|
+
const seenArtifactNames = new Set();
|
|
131
|
+
for (const artifact of artifacts) {
|
|
132
|
+
if (!seenArtifactNames.has(artifact.name)) {
|
|
133
|
+
latestArtifacts.push(artifact);
|
|
134
|
+
seenArtifactNames.add(artifact.name);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return latestArtifacts;
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=list-artifacts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-artifacts.js","sourceRoot":"","sources":["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AS,SAAS,CAAC,MAAM,cAAc,CAAC,CAAA;QAE7C,OAAO;YACL,SAAS;SACV,CAAA;IACH,CAAC;CAAA;AAhCD,sDAgCC;AAED;;;;GAIG;AACH,SAAS,YAAY,CAAC,SAAqB;IACzC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAA;IACrC,MAAM,eAAe,GAAe,EAAE,CAAA;IACtC,MAAM,iBAAiB,GAAG,IAAI,GAAG,EAAU,CAAA;IAC3C,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE;QAChC,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;YACzC,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;YAC9B,iBAAiB,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;SACrC;KACF;IACD,OAAO,eAAe,CAAA;AACxB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { OctokitOptions } from '@octokit/core/dist-types/types';
|
|
2
|
+
import { RequestRequestOptions } from '@octokit/types';
|
|
3
|
+
export type RetryOptions = {
|
|
4
|
+
doNotRetry?: number[];
|
|
5
|
+
enabled?: boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare function getRetryOptions(defaultOptions: OctokitOptions, retries?: number, exemptStatusCodes?: number[]): [RetryOptions, RequestRequestOptions | undefined];
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.getRetryOptions = void 0;
|
|
27
|
+
const core = __importStar(require("@actions/core"));
|
|
28
|
+
// Defaults for fetching artifacts
|
|
29
|
+
const defaultMaxRetryNumber = 5;
|
|
30
|
+
const defaultExemptStatusCodes = [400, 401, 403, 404, 422]; // https://github.com/octokit/plugin-retry.js/blob/9a2443746c350b3beedec35cf26e197ea318a261/src/index.ts#L14
|
|
31
|
+
function getRetryOptions(defaultOptions, retries = defaultMaxRetryNumber, exemptStatusCodes = defaultExemptStatusCodes) {
|
|
32
|
+
var _a;
|
|
33
|
+
if (retries <= 0) {
|
|
34
|
+
return [{ enabled: false }, defaultOptions.request];
|
|
35
|
+
}
|
|
36
|
+
const retryOptions = {
|
|
37
|
+
enabled: true
|
|
38
|
+
};
|
|
39
|
+
if (exemptStatusCodes.length > 0) {
|
|
40
|
+
retryOptions.doNotRetry = exemptStatusCodes;
|
|
41
|
+
}
|
|
42
|
+
// The GitHub type has some defaults for `options.request`
|
|
43
|
+
// see: https://github.com/actions/toolkit/blob/4fbc5c941a57249b19562015edbd72add14be93d/packages/github/src/utils.ts#L15
|
|
44
|
+
// We pass these in here so they are not overridden.
|
|
45
|
+
const requestOptions = Object.assign(Object.assign({}, defaultOptions.request), { retries });
|
|
46
|
+
core.debug(`GitHub client configured with: (retries: ${requestOptions.retries}, retry-exempt-status-code: ${(_a = retryOptions.doNotRetry) !== null && _a !== void 0 ? _a : 'octokit default: [400, 401, 403, 404, 422]'})`);
|
|
47
|
+
return [retryOptions, requestOptions];
|
|
48
|
+
}
|
|
49
|
+
exports.getRetryOptions = getRetryOptions;
|
|
50
|
+
//# sourceMappingURL=retry-options.js.map
|