Skip to content

Commit f9fbe79

Browse files
committed
use actions/core
1 parent 50462ce commit f9fbe79

File tree

5 files changed

+41
-15
lines changed

5 files changed

+41
-15
lines changed

scripts/ci/githubActions/createMatrix.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
/* eslint-disable no-console,no-case-declarations */
2+
import * as core from '@actions/core';
3+
24
import { CLIENTS, createClientName, GENERATORS, LANGUAGES } from '../../common';
35
import {
46
getClientsConfigField,
@@ -17,7 +19,7 @@ import type {
1719
SpecMatrix,
1820
ToRunMatrix,
1921
} from './types';
20-
import { computeCacheKey, isBaseChanged, setOutput } from './utils';
22+
import { computeCacheKey, isBaseChanged } from './utils';
2123

2224
// This empty matrix is required by the CI, otherwise it throws
2325
const EMPTY_MATRIX = { client: ['no-run'] };
@@ -155,8 +157,8 @@ async function getClientMatrix(baseBranch: string): Promise<void> {
155157

156158
const shouldRun = clientMatrix.client.length > 0;
157159

158-
await setOutput('RUN_GEN', shouldRun);
159-
await setOutput(
160+
core.setOutput('RUN_GEN', shouldRun);
161+
core.setOutput(
160162
'GEN_MATRIX',
161163
JSON.stringify(shouldRun ? clientMatrix : EMPTY_MATRIX)
162164
);
@@ -186,7 +188,7 @@ async function getSpecMatrix(): Promise<void> {
186188
]),
187189
};
188190

189-
await setOutput('MATRIX', JSON.stringify(ciMatrix));
191+
core.setOutput('MATRIX', JSON.stringify(ciMatrix));
190192
}
191193

192194
/**

scripts/ci/githubActions/setRunVariables.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
/* eslint-disable no-console */
2+
import * as core from '@actions/core';
3+
24
import { CLIENTS_JS_UTILS } from '../../common';
35
import { getLanguageFolder } from '../../config';
46

5-
import { isBaseChanged, setOutput } from './utils';
7+
import { isBaseChanged } from './utils';
68

79
const JS_CLIENT_FOLDER = getLanguageFolder('javascript');
810
const JAVA_CLIENT_FOLDER = getLanguageFolder('java');
@@ -81,7 +83,7 @@ async function setRunVariables({
8183
}): Promise<void> {
8284
console.log(`Checking diff between ${originBranch} and HEAD`);
8385

84-
await setOutput('ORIGIN_BRANCH', originBranch);
86+
core.setOutput('ORIGIN_BRANCH', originBranch);
8587

8688
await isBaseChanged(originBranch, DEPENDENCIES, true);
8789
}

scripts/ci/githubActions/utils.ts

+2-8
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
/* eslint-disable no-console */
22
import crypto from 'crypto';
3-
import fsp from 'fs/promises';
4-
import { EOL } from 'os';
53

4+
import * as core from '@actions/core';
65
import { hashElement } from 'folder-hash';
76

87
import { toAbsolutePath } from '../../common';
@@ -79,16 +78,11 @@ export async function isBaseChanged(
7978

8079
if (output) {
8180
console.log(`Found ${diff} changes for '${key}'`);
82-
await setOutput(key, diff);
81+
core.setOutput(key, diff);
8382
} else if (diff > 0) {
8483
return true;
8584
}
8685
}
8786

8887
return false;
8988
}
90-
91-
export async function setOutput(key: string, value: any): Promise<void> {
92-
const output = process.env.GITHUB_OUTPUT!;
93-
await fsp.writeFile(output, `${key}=${value}${EOL}`);
94-
}

scripts/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"upsertGenerationComment": "ts-node ci/codegen/upsertGenerationComment.ts"
1414
},
1515
"devDependencies": {
16+
"@actions/core": "1.10.0",
1617
"@octokit/rest": "19.0.7",
1718
"@types/folder-hash": "4.0.2",
1819
"@types/inquirer": "8.2.6",

yarn.lock

+28-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,25 @@ __metadata:
55
version: 6
66
cacheKey: 8
77

8+
"@actions/core@npm:1.10.0":
9+
version: 1.10.0
10+
resolution: "@actions/core@npm:1.10.0"
11+
dependencies:
12+
"@actions/http-client": ^2.0.1
13+
uuid: ^8.3.2
14+
checksum: 0a75621e007ab20d887434cdd165f0b9036f14c22252a2faed33543d8b9d04ec95d823e69ca636a25245574e4585d73e1e9e47a845339553c664f9f2c9614669
15+
languageName: node
16+
linkType: hard
17+
18+
"@actions/http-client@npm:^2.0.1":
19+
version: 2.0.1
20+
resolution: "@actions/http-client@npm:2.0.1"
21+
dependencies:
22+
tunnel: ^0.0.6
23+
checksum: 799ec3df91e28a9da91ce6592e94f8b8923ccf6cc21a2f72c7429be5af5273f1625335411adc2a1bb222d56c852d5767214dfa6fa32a6da7e81dba8290e08f17
24+
languageName: node
25+
linkType: hard
26+
827
"@algolia/api-client-automation@workspace:.":
928
version: 0.0.0-use.local
1029
resolution: "@algolia/api-client-automation@workspace:."
@@ -7943,6 +7962,7 @@ __metadata:
79437962
version: 0.0.0-use.local
79447963
resolution: "scripts@workspace:scripts"
79457964
dependencies:
7965+
"@actions/core": 1.10.0
79467966
"@octokit/rest": 19.0.7
79477967
"@types/folder-hash": 4.0.2
79487968
"@types/inquirer": 8.2.6
@@ -8686,6 +8706,13 @@ __metadata:
86868706
languageName: node
86878707
linkType: hard
86888708

8709+
"tunnel@npm:^0.0.6":
8710+
version: 0.0.6
8711+
resolution: "tunnel@npm:0.0.6"
8712+
checksum: c362948df9ad34b649b5585e54ce2838fa583aa3037091aaed66793c65b423a264e5229f0d7e9a95513a795ac2bd4cb72cda7e89a74313f182c1e9ae0b0994fa
8713+
languageName: node
8714+
linkType: hard
8715+
86898716
"type-check@npm:^0.4.0, type-check@npm:~0.4.0":
86908717
version: 0.4.0
86918718
resolution: "type-check@npm:0.4.0"
@@ -8837,7 +8864,7 @@ __metadata:
88378864
languageName: node
88388865
linkType: hard
88398866

8840-
"uuid@npm:8.3.2":
8867+
"uuid@npm:8.3.2, uuid@npm:^8.3.2":
88418868
version: 8.3.2
88428869
resolution: "uuid@npm:8.3.2"
88438870
bin:

0 commit comments

Comments
 (0)