Skip to content

Commit 116f55c

Browse files
alan-agius4alxhub
authored andcommitted
refactor(docs-infra): use Node.js temp APIs in deploy action
Replaces the 'tmp' package with native 'node:os' and 'node:fs' APIs to create temporary files in the system temp directory.
1 parent 0fcc120 commit 116f55c

6 files changed

Lines changed: 33 additions & 426 deletions

File tree

.github/actions/deploy-docs-site/BUILD.bazel

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,5 @@ ts_project(
3535
"//:node_modules/@actions/github",
3636
"//:node_modules/@angular/ng-dev",
3737
"//:node_modules/@types/node",
38-
"//:node_modules/@types/tmp",
39-
"//:node_modules/tmp",
4038
],
4139
)

.github/actions/deploy-docs-site/lib/credential.mts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
import {fileSync} from 'tmp';
2-
import {writeSync} from 'node:fs';
1+
import {writeFileSync, mkdtempSync} from 'node:fs';
2+
import {join} from 'node:path';
3+
import {tmpdir} from 'node:os';
34
import {getInput, setSecret} from '@actions/core';
45

56
let credentialFilePath: undefined | string;
67

78
export function getCredentialFilePath(): string {
89
if (credentialFilePath === undefined) {
9-
const tmpFile = fileSync({postfix: '.json'});
10-
writeSync(tmpFile.fd, getInput('serviceKey', {required: true}));
11-
setSecret(tmpFile.name);
12-
credentialFilePath = tmpFile.name;
10+
const tmpDir = mkdtempSync(join(tmpdir(), 'credential-'));
11+
const filePath = join(tmpDir, 'credential.json');
12+
writeFileSync(filePath, getInput('serviceKey', {required: true}));
13+
setSecret(filePath);
14+
credentialFilePath = filePath;
1315
}
1416
return credentialFilePath;
1517
}

.github/actions/deploy-docs-site/lib/deployments.mts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
import {fetchLongTermSupportBranchesFromNpm, ActiveReleaseTrains} from '@angular/ng-dev';
2-
import {ReleaseConfig} from '@angular/ng-dev';
3-
import {AuthenticatedGitClient} from '@angular/ng-dev';
1+
import {
2+
fetchLongTermSupportBranchesFromNpm,
3+
ActiveReleaseTrains,
4+
AuthenticatedGitClient,
5+
ReleaseConfig,
6+
} from '@angular/ng-dev';
47

58
export interface Deployment {
69
branch: string;

0 commit comments

Comments
 (0)