@actions/core 1.3.0 → 1.6.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 CHANGED
@@ -23,6 +23,7 @@ Outputs can be set with `setOutput` which makes them available to be mapped into
23
23
  ```js
24
24
  const myInput = core.getInput('inputName', { required: true });
25
25
  const myBooleanInput = core.getBooleanInput('booleanInputName', { required: true });
26
+ const myMultilineInput = core.getMultilineInput('multilineInputName', { required: true });
26
27
  core.setOutput('outputKey', 'outputVal');
27
28
  ```
28
29
 
@@ -91,6 +92,8 @@ try {
91
92
 
92
93
  // Do stuff
93
94
  core.info('Output to the actions build log')
95
+
96
+ core.notice('This is a message that will also emit an annotation')
94
97
  }
95
98
  catch (err) {
96
99
  core.error(`Error ${err}, action may still succeed though`);
@@ -114,6 +117,59 @@ const result = await core.group('Do something async', async () => {
114
117
  })
115
118
  ```
116
119
 
120
+ #### Annotations
121
+
122
+ This library has 3 methods that will produce [annotations](https://docs.github.com/en/rest/reference/checks#create-a-check-run).
123
+ ```js
124
+ core.error('This is a bad error. This will also fail the build.')
125
+
126
+ core.warning('Something went wrong, but it\'s not bad enough to fail the build.')
127
+
128
+ core.notice('Something happened that you might want to know about.')
129
+ ```
130
+
131
+ These will surface to the UI in the Actions page and on Pull Requests. They look something like this:
132
+
133
+ ![Annotations Image](../../docs/assets/annotations.png)
134
+
135
+ These annotations can also be attached to particular lines and columns of your source files to show exactly where a problem is occuring.
136
+
137
+ These options are:
138
+ ```typescript
139
+ export interface AnnotationProperties {
140
+ /**
141
+ * A title for the annotation.
142
+ */
143
+ title?: string
144
+
145
+ /**
146
+ * The name of the file for which the annotation should be created.
147
+ */
148
+ file?: string
149
+
150
+ /**
151
+ * The start line for the annotation.
152
+ */
153
+ startLine?: number
154
+
155
+ /**
156
+ * The end line for the annotation. Defaults to `startLine` when `startLine` is provided.
157
+ */
158
+ endLine?: number
159
+
160
+ /**
161
+ * The start column for the annotation. Cannot be sent when `startLine` and `endLine` are different values.
162
+ */
163
+ startColumn?: number
164
+
165
+ /**
166
+ * The start column for the annotation. Cannot be sent when `startLine` and `endLine` are different values.
167
+ * Defaults to `startColumn` when `startColumn` is provided.
168
+ */
169
+ endColumn?: number
170
+ }
171
+ ```
172
+
117
173
  #### Styling output
118
174
 
119
175
  Colored output is supported in the Action logs via standard [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code). 3/4 bit, 8 bit and 24 bit colors are all supported.
@@ -206,3 +262,51 @@ var pid = core.getState("pidToKill");
206
262
 
207
263
  process.kill(pid);
208
264
  ```
265
+
266
+ #### OIDC Token
267
+
268
+ You can use these methods to interact with the GitHub OIDC provider and get a JWT ID token which would help to get access token from third party cloud providers.
269
+
270
+ **Method Name**: getIDToken()
271
+
272
+ **Inputs**
273
+
274
+ audience : optional
275
+
276
+ **Outputs**
277
+
278
+ A [JWT](https://jwt.io/) ID Token
279
+
280
+ In action's `main.ts`:
281
+ ```js
282
+ const core = require('@actions/core');
283
+ async function getIDTokenAction(): Promise<void> {
284
+
285
+ const audience = core.getInput('audience', {required: false})
286
+
287
+ const id_token1 = await core.getIDToken() // ID Token with default audience
288
+ const id_token2 = await core.getIDToken(audience) // ID token with custom audience
289
+
290
+ // this id_token can be used to get access token from third party cloud providers
291
+ }
292
+ getIDTokenAction()
293
+ ```
294
+
295
+ In action's `actions.yml`:
296
+
297
+ ```yaml
298
+ name: 'GetIDToken'
299
+ description: 'Get ID token from Github OIDC provider'
300
+ inputs:
301
+ audience:
302
+ description: 'Audience for which the ID token is intended for'
303
+ required: false
304
+ outputs:
305
+ id_token1:
306
+ description: 'ID token obtained from OIDC provider'
307
+ id_token2:
308
+ description: 'ID token obtained from OIDC provider'
309
+ runs:
310
+ using: 'node12'
311
+ main: 'dist/index.js'
312
+ ```
package/lib/command.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- interface CommandProperties {
1
+ export interface CommandProperties {
2
2
  [key: string]: any;
3
3
  }
4
4
  /**
@@ -13,4 +13,3 @@ interface CommandProperties {
13
13
  */
14
14
  export declare function issueCommand(command: string, properties: CommandProperties, message: any): void;
15
15
  export declare function issue(name: string, message?: string): void;
16
- export {};
package/lib/core.d.ts CHANGED
@@ -20,6 +20,37 @@ export declare enum ExitCode {
20
20
  */
21
21
  Failure = 1
22
22
  }
23
+ /**
24
+ * Optional properties that can be sent with annotatation commands (notice, error, and warning)
25
+ * See: https://docs.github.com/en/rest/reference/checks#create-a-check-run for more information about annotations.
26
+ */
27
+ export interface AnnotationProperties {
28
+ /**
29
+ * A title for the annotation.
30
+ */
31
+ title?: string;
32
+ /**
33
+ * The path of the file for which the annotation should be created.
34
+ */
35
+ file?: string;
36
+ /**
37
+ * The start line for the annotation.
38
+ */
39
+ startLine?: number;
40
+ /**
41
+ * The end line for the annotation. Defaults to `startLine` when `startLine` is provided.
42
+ */
43
+ endLine?: number;
44
+ /**
45
+ * The start column for the annotation. Cannot be sent when `startLine` and `endLine` are different values.
46
+ */
47
+ startColumn?: number;
48
+ /**
49
+ * The start column for the annotation. Cannot be sent when `startLine` and `endLine` are different values.
50
+ * Defaults to `startColumn` when `startColumn` is provided.
51
+ */
52
+ endColumn?: number;
53
+ }
23
54
  /**
24
55
  * Sets env variable for this action and future actions in the job
25
56
  * @param name the name of the variable to set
@@ -46,6 +77,15 @@ export declare function addPath(inputPath: string): void;
46
77
  * @returns string
47
78
  */
48
79
  export declare function getInput(name: string, options?: InputOptions): string;
80
+ /**
81
+ * Gets the values of an multiline input. Each value is also trimmed.
82
+ *
83
+ * @param name name of the input to get
84
+ * @param options optional. See InputOptions.
85
+ * @returns string[]
86
+ *
87
+ */
88
+ export declare function getMultilineInput(name: string, options?: InputOptions): string[];
49
89
  /**
50
90
  * Gets the input value of the boolean type in the YAML 1.2 "core schema" specification.
51
91
  * Support boolean input list: `true | True | TRUE | false | False | FALSE` .
@@ -88,13 +128,21 @@ export declare function debug(message: string): void;
88
128
  /**
89
129
  * Adds an error issue
90
130
  * @param message error issue message. Errors will be converted to string via toString()
131
+ * @param properties optional properties to add to the annotation.
91
132
  */
92
- export declare function error(message: string | Error): void;
133
+ export declare function error(message: string | Error, properties?: AnnotationProperties): void;
93
134
  /**
94
- * Adds an warning issue
135
+ * Adds a warning issue
95
136
  * @param message warning issue message. Errors will be converted to string via toString()
137
+ * @param properties optional properties to add to the annotation.
138
+ */
139
+ export declare function warning(message: string | Error, properties?: AnnotationProperties): void;
140
+ /**
141
+ * Adds a notice issue
142
+ * @param message notice issue message. Errors will be converted to string via toString()
143
+ * @param properties optional properties to add to the annotation.
96
144
  */
97
- export declare function warning(message: string | Error): void;
145
+ export declare function notice(message: string | Error, properties?: AnnotationProperties): void;
98
146
  /**
99
147
  * Writes info to log with console.log.
100
148
  * @param message info message
@@ -135,3 +183,4 @@ export declare function saveState(name: string, value: any): void;
135
183
  * @returns string
136
184
  */
137
185
  export declare function getState(name: string): string;
186
+ export declare function getIDToken(aud?: string): Promise<string>;
package/lib/core.js CHANGED
@@ -28,12 +28,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
28
28
  });
29
29
  };
30
30
  Object.defineProperty(exports, "__esModule", { value: true });
31
- exports.getState = exports.saveState = exports.group = exports.endGroup = exports.startGroup = exports.info = exports.warning = exports.error = exports.debug = exports.isDebug = exports.setFailed = exports.setCommandEcho = exports.setOutput = exports.getBooleanInput = exports.getInput = exports.addPath = exports.setSecret = exports.exportVariable = exports.ExitCode = void 0;
31
+ exports.getIDToken = exports.getState = exports.saveState = exports.group = exports.endGroup = exports.startGroup = exports.info = exports.notice = exports.warning = exports.error = exports.debug = exports.isDebug = exports.setFailed = exports.setCommandEcho = exports.setOutput = exports.getBooleanInput = exports.getMultilineInput = exports.getInput = exports.addPath = exports.setSecret = exports.exportVariable = exports.ExitCode = void 0;
32
32
  const command_1 = require("./command");
33
33
  const file_command_1 = require("./file-command");
34
34
  const utils_1 = require("./utils");
35
35
  const os = __importStar(require("os"));
36
36
  const path = __importStar(require("path"));
37
+ const oidc_utils_1 = require("./oidc-utils");
37
38
  /**
38
39
  * The code to exit an action
39
40
  */
@@ -114,6 +115,21 @@ function getInput(name, options) {
114
115
  return val.trim();
115
116
  }
116
117
  exports.getInput = getInput;
118
+ /**
119
+ * Gets the values of an multiline input. Each value is also trimmed.
120
+ *
121
+ * @param name name of the input to get
122
+ * @param options optional. See InputOptions.
123
+ * @returns string[]
124
+ *
125
+ */
126
+ function getMultilineInput(name, options) {
127
+ const inputs = getInput(name, options)
128
+ .split('\n')
129
+ .filter(x => x !== '');
130
+ return inputs;
131
+ }
132
+ exports.getMultilineInput = getMultilineInput;
117
133
  /**
118
134
  * Gets the input value of the boolean type in the YAML 1.2 "core schema" specification.
119
135
  * Support boolean input list: `true | True | TRUE | false | False | FALSE` .
@@ -191,19 +207,30 @@ exports.debug = debug;
191
207
  /**
192
208
  * Adds an error issue
193
209
  * @param message error issue message. Errors will be converted to string via toString()
210
+ * @param properties optional properties to add to the annotation.
194
211
  */
195
- function error(message) {
196
- command_1.issue('error', message instanceof Error ? message.toString() : message);
212
+ function error(message, properties = {}) {
213
+ command_1.issueCommand('error', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);
197
214
  }
198
215
  exports.error = error;
199
216
  /**
200
- * Adds an warning issue
217
+ * Adds a warning issue
201
218
  * @param message warning issue message. Errors will be converted to string via toString()
219
+ * @param properties optional properties to add to the annotation.
202
220
  */
203
- function warning(message) {
204
- command_1.issue('warning', message instanceof Error ? message.toString() : message);
221
+ function warning(message, properties = {}) {
222
+ command_1.issueCommand('warning', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);
205
223
  }
206
224
  exports.warning = warning;
225
+ /**
226
+ * Adds a notice issue
227
+ * @param message notice issue message. Errors will be converted to string via toString()
228
+ * @param properties optional properties to add to the annotation.
229
+ */
230
+ function notice(message, properties = {}) {
231
+ command_1.issueCommand('notice', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);
232
+ }
233
+ exports.notice = notice;
207
234
  /**
208
235
  * Writes info to log with console.log.
209
236
  * @param message info message
@@ -276,4 +303,10 @@ function getState(name) {
276
303
  return process.env[`STATE_${name}`] || '';
277
304
  }
278
305
  exports.getState = getState;
306
+ function getIDToken(aud) {
307
+ return __awaiter(this, void 0, void 0, function* () {
308
+ return yield oidc_utils_1.OidcClient.getIDToken(aud);
309
+ });
310
+ }
311
+ exports.getIDToken = getIDToken;
279
312
  //# sourceMappingURL=core.js.map
package/lib/core.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"core.js","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAA6C;AAC7C,iDAA+D;AAC/D,mCAAsC;AAEtC,uCAAwB;AACxB,2CAA4B;AAa5B;;GAEG;AACH,IAAY,QAUX;AAVD,WAAY,QAAQ;IAClB;;OAEG;IACH,6CAAW,CAAA;IAEX;;OAEG;IACH,6CAAW,CAAA;AACb,CAAC,EAVW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAUnB;AAED,yEAAyE;AACzE,YAAY;AACZ,yEAAyE;AAEzE;;;;GAIG;AACH,8DAA8D;AAC9D,SAAgB,cAAc,CAAC,IAAY,EAAE,GAAQ;IACnD,MAAM,YAAY,GAAG,sBAAc,CAAC,GAAG,CAAC,CAAA;IACxC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,YAAY,CAAA;IAEhC,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,EAAE,CAAA;IAChD,IAAI,QAAQ,EAAE;QACZ,MAAM,SAAS,GAAG,qCAAqC,CAAA;QACvD,MAAM,YAAY,GAAG,GAAG,IAAI,KAAK,SAAS,GAAG,EAAE,CAAC,GAAG,GAAG,YAAY,GAAG,EAAE,CAAC,GAAG,GAAG,SAAS,EAAE,CAAA;QACzF,2BAAgB,CAAC,KAAK,EAAE,YAAY,CAAC,CAAA;KACtC;SAAM;QACL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H,SAAgB,IAAI,CAAC,OAAe;IAClC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,GAAG,EAAE,CAAC,GAAG,CAAC,CAAA;AACxC,CAAC;AAFD,oBAEC;AAED;;;;;;GAMG;AACH,SAAgB,UAAU,CAAC,IAAY;IACrC,eAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;AACtB,CAAC;AAFD,gCAEC;AAED;;GAEG;AACH,SAAgB,QAAQ;IACtB,eAAK,CAAC,UAAU,CAAC,CAAA;AACnB,CAAC;AAFD,4BAEC;AAED;;;;;;;GAOG;AACH,SAAsB,KAAK,CAAI,IAAY,EAAE,EAAoB;;QAC/D,UAAU,CAAC,IAAI,CAAC,CAAA;QAEhB,IAAI,MAAS,CAAA;QAEb,IAAI;YACF,MAAM,GAAG,MAAM,EAAE,EAAE,CAAA;SACpB;gBAAS;YACR,QAAQ,EAAE,CAAA;SACX;QAED,OAAO,MAAM,CAAA;IACf,CAAC;CAAA;AAZD,sBAYC;AAED,yEAAyE;AACzE,uBAAuB;AACvB,yEAAyE;AAEzE;;;;;GAKG;AACH,8DAA8D;AAC9D,SAAgB,SAAS,CAAC,IAAY,EAAE,KAAU;IAChD,sBAAY,CAAC,YAAY,EAAE,EAAC,IAAI,EAAC,EAAE,KAAK,CAAC,CAAA;AAC3C,CAAC;AAFD,8BAEC;AAED;;;;;GAKG;AACH,SAAgB,QAAQ,CAAC,IAAY;IACnC,OAAO,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,EAAE,CAAC,IAAI,EAAE,CAAA;AAC3C,CAAC;AAFD,4BAEC;AAED,SAAsB,UAAU,CAAC,GAAY;;QAC3C,OAAO,MAAM,uBAAU,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;IACzC,CAAC;CAAA;AAFD,gCAEC"}
@@ -0,0 +1,7 @@
1
+ export declare class OidcClient {
2
+ private static createHttpClient;
3
+ private static getRequestToken;
4
+ private static getIDTokenUrl;
5
+ private static getCall;
6
+ static getIDToken(audience?: string): Promise<string>;
7
+ }
@@ -0,0 +1,77 @@
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.OidcClient = void 0;
13
+ const http_client_1 = require("@actions/http-client");
14
+ const auth_1 = require("@actions/http-client/auth");
15
+ const core_1 = require("./core");
16
+ class OidcClient {
17
+ static createHttpClient(allowRetry = true, maxRetry = 10) {
18
+ const requestOptions = {
19
+ allowRetries: allowRetry,
20
+ maxRetries: maxRetry
21
+ };
22
+ return new http_client_1.HttpClient('actions/oidc-client', [new auth_1.BearerCredentialHandler(OidcClient.getRequestToken())], requestOptions);
23
+ }
24
+ static getRequestToken() {
25
+ const token = process.env['ACTIONS_ID_TOKEN_REQUEST_TOKEN'];
26
+ if (!token) {
27
+ throw new Error('Unable to get ACTIONS_ID_TOKEN_REQUEST_TOKEN env variable');
28
+ }
29
+ return token;
30
+ }
31
+ static getIDTokenUrl() {
32
+ const runtimeUrl = process.env['ACTIONS_ID_TOKEN_REQUEST_URL'];
33
+ if (!runtimeUrl) {
34
+ throw new Error('Unable to get ACTIONS_ID_TOKEN_REQUEST_URL env variable');
35
+ }
36
+ return runtimeUrl;
37
+ }
38
+ static getCall(id_token_url) {
39
+ var _a;
40
+ return __awaiter(this, void 0, void 0, function* () {
41
+ const httpclient = OidcClient.createHttpClient();
42
+ const res = yield httpclient
43
+ .getJson(id_token_url)
44
+ .catch(error => {
45
+ throw new Error(`Failed to get ID Token. \n
46
+ Error Code : ${error.statusCode}\n
47
+ Error Message: ${error.result.message}`);
48
+ });
49
+ const id_token = (_a = res.result) === null || _a === void 0 ? void 0 : _a.value;
50
+ if (!id_token) {
51
+ throw new Error('Response json body do not have ID Token field');
52
+ }
53
+ return id_token;
54
+ });
55
+ }
56
+ static getIDToken(audience) {
57
+ return __awaiter(this, void 0, void 0, function* () {
58
+ try {
59
+ // New ID Token is requested from action service
60
+ let id_token_url = OidcClient.getIDTokenUrl();
61
+ if (audience) {
62
+ const encodedAudience = encodeURIComponent(audience);
63
+ id_token_url = `${id_token_url}&audience=${encodedAudience}`;
64
+ }
65
+ core_1.debug(`ID token url is ${id_token_url}`);
66
+ const id_token = yield OidcClient.getCall(id_token_url);
67
+ core_1.setSecret(id_token);
68
+ return id_token;
69
+ }
70
+ catch (error) {
71
+ throw new Error(`Error message: ${error.message}`);
72
+ }
73
+ });
74
+ }
75
+ }
76
+ exports.OidcClient = OidcClient;
77
+ //# sourceMappingURL=oidc-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oidc-utils.js","sourceRoot":"","sources":["../src/oidc-utils.ts"],"names":[],"mappings":";;;;;;;;;;;;AAGA,sDAA+C;AAC/C,oDAAiE;AACjE,iCAAuC;AAKvC,MAAa,UAAU;IACb,MAAM,CAAC,gBAAgB,CAC7B,UAAU,GAAG,IAAI,EACjB,QAAQ,GAAG,EAAE;QAEb,MAAM,cAAc,GAAoB;YACtC,YAAY,EAAE,UAAU;YACxB,UAAU,EAAE,QAAQ;SACrB,CAAA;QAED,OAAO,IAAI,wBAAU,CACnB,qBAAqB,EACrB,CAAC,IAAI,8BAAuB,CAAC,UAAU,CAAC,eAAe,EAAE,CAAC,CAAC,EAC3D,cAAc,CACf,CAAA;IACH,CAAC;IAEO,MAAM,CAAC,eAAe;QAC5B,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAA;QAC3D,IAAI,CAAC,KAAK,EAAE;Y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C,QAAQ,CAAC,CAAA;gBACnB,OAAO,QAAQ,CAAA;aAChB;YAAC,OAAO,KAAK,EAAE;gBACd,MAAM,IAAI,KAAK,CAAC,kBAAkB,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;aACnD;QACH,CAAC;KAAA;CACF;AAzED,gCAyEC"}
package/lib/utils.d.ts CHANGED
@@ -1,5 +1,14 @@
1
+ import { AnnotationProperties } from './core';
2
+ import { CommandProperties } from './command';
1
3
  /**
2
4
  * Sanitizes an input into a string so it can be passed into issueCommand safely
3
5
  * @param input input to sanitize into a string
4
6
  */
5
7
  export declare function toCommandValue(input: any): string;
8
+ /**
9
+ *
10
+ * @param annotationProperties
11
+ * @returns The command properties to send with the actual annotation command
12
+ * See IssueCommandProperties: https://github.com/actions/runner/blob/main/src/Runner.Worker/ActionCommandManager.cs#L646
13
+ */
14
+ export declare function toCommandProperties(annotationProperties: AnnotationProperties): CommandProperties;
package/lib/utils.js CHANGED
@@ -2,7 +2,7 @@
2
2
  // We use any as a valid input type
3
3
  /* eslint-disable @typescript-eslint/no-explicit-any */
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.toCommandValue = void 0;
5
+ exports.toCommandProperties = exports.toCommandValue = void 0;
6
6
  /**
7
7
  * Sanitizes an input into a string so it can be passed into issueCommand safely
8
8
  * @param input input to sanitize into a string
@@ -17,4 +17,24 @@ function toCommandValue(input) {
17
17
  return JSON.stringify(input);
18
18
  }
19
19
  exports.toCommandValue = toCommandValue;
20
+ /**
21
+ *
22
+ * @param annotationProperties
23
+ * @returns The command properties to send with the actual annotation command
24
+ * See IssueCommandProperties: https://github.com/actions/runner/blob/main/src/Runner.Worker/ActionCommandManager.cs#L646
25
+ */
26
+ function toCommandProperties(annotationProperties) {
27
+ if (!Object.keys(annotationProperties).length) {
28
+ return {};
29
+ }
30
+ return {
31
+ title: annotationProperties.title,
32
+ file: annotationProperties.file,
33
+ line: annotationProperties.startLine,
34
+ endLine: annotationProperties.endLine,
35
+ col: annotationProperties.startColumn,
36
+ endColumn: annotationProperties.endColumn
37
+ };
38
+ }
39
+ exports.toCommandProperties = toCommandProperties;
20
40
  //# sourceMappingURL=utils.js.map
package/lib/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";AAAA,mCAAmC;AACnC,uDAAuD;;;AAEvD;;;GAGG;AACH,SAAgB,cAAc,CAAC,KAAU;IACvC,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE;QACzC,OAAO,EAAE,CAAA;KACV;SAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,YAAY,MAAM,EAAE;QAC/D,OAAO,KAAe,CAAA;KACvB;IACD,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;AAC9B,CAAC;AAPD,wCAOC"}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";AAAA,mCAAmC;AACnC,uDAAuD;;;AAKvD;;;GAGG;AACH,SAAgB,cAAc,CAAC,KAAU;IACvC,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE;QACzC,OAAO,EAAE,CAAA;KACV;SAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,YAAY,MAAM,EAAE;QAC/D,OAAO,KAAe,CAAA;KACvB;IACD,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;AAC9B,CAAC;AAPD,wCAOC;AAED;;;;;GAKG;AACH,SAAgB,mBAAmB,CACjC,oBAA0C;IAE1C,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC,MAAM,EAAE;QAC7C,OAAO,EAAE,CAAA;KACV;IAED,OAAO;QACL,KAAK,EAAE,oBAAoB,CAAC,KAAK;QACjC,IAAI,EAAE,oBAAoB,CAAC,IAAI;QAC/B,IAAI,EAAE,oBAAoB,CAAC,SAAS;QACpC,OAAO,EAAE,oBAAoB,CAAC,OAAO;QACrC,GAAG,EAAE,oBAAoB,CAAC,WAAW;QACrC,SAAS,EAAE,oBAAoB,CAAC,SAAS;KAC1C,CAAA;AACH,CAAC;AAfD,kDAeC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@actions/core",
3
- "version": "1.3.0",
3
+ "version": "1.6.0",
4
4
  "description": "Actions core lib",
5
5
  "keywords": [
6
6
  "github",
@@ -35,6 +35,9 @@
35
35
  "bugs": {
36
36
  "url": "https://github.com/actions/toolkit/issues"
37
37
  },
38
+ "dependencies": {
39
+ "@actions/http-client": "^1.0.11"
40
+ },
38
41
  "devDependencies": {
39
42
  "@types/node": "^12.0.2"
40
43
  }