Skip to content

Commit bf2364e

Browse files
committed
Merge branch 'main' into dev
# Conflicts: # .angular-github/actions/deploy-docs-site/lib/sitemap.mts # .angular-github/workflows/update-cdk-apis-and-cli-help.yml
2 parents 8a15d1a + 2ddf26e commit bf2364e

File tree

2,069 files changed

+158717
-85614
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,069 files changed

+158717
-85614
lines changed

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {cp, mkdtemp, readFile, rm, writeFile} from 'node:fs/promises';
1+
import {mkdtemp, readFile, rm, writeFile} from 'node:fs/promises';
22
import {Deployment} from './deployments.mjs';
33
import {join} from 'node:path';
44

@@ -9,7 +9,7 @@ import {getCredentialFilePath} from './credential.mjs';
99
export async function deployToFirebase(
1010
deployment: Deployment,
1111
configPath: string,
12-
distDirPath: string,
12+
stagingDir: string,
1313
) {
1414
if (deployment.destination == undefined) {
1515
console.log(`No deployment necessary for docs created from: ${deployment.branch}`);
@@ -18,37 +18,33 @@ export async function deployToFirebase(
1818

1919
console.log('Preparing for deployment to firebase...');
2020

21-
const tmpDeployDir = await mkdtemp(join(tmpdir(), 'deploy-directory'));
22-
const deployConfigPath = join(tmpDeployDir, 'firebase.json');
21+
const deployConfigPath = join(stagingDir, 'firebase.json');
2322

2423
const config = JSON.parse(await readFile(configPath, {encoding: 'utf-8'})) as {
2524
hosting: {public: string};
2625
};
27-
config['hosting']['public'] = './dist';
26+
config['hosting']['public'] = './browser';
2827

2928
await writeFile(deployConfigPath, JSON.stringify(config, null, 2));
3029

31-
await cp(distDirPath, join(tmpDeployDir, 'dist'), {recursive: true});
32-
spawnSync(`chmod 777 -R ${tmpDeployDir}`, {encoding: 'utf-8', shell: true});
33-
3430
firebase(
3531
`target:clear --config ${deployConfigPath} --project angular-dev-site hosting angular-docs`,
36-
tmpDeployDir,
32+
stagingDir,
3733
);
3834
firebase(
3935
`target:apply --config ${deployConfigPath} --project angular-dev-site hosting angular-docs ${deployment.destination}`,
40-
tmpDeployDir,
36+
stagingDir,
4137
);
4238
firebase(
4339
`deploy --config ${deployConfigPath} --project angular-dev-site --only hosting --non-interactive`,
44-
tmpDeployDir,
40+
stagingDir,
4541
);
4642
firebase(
4743
`target:clear --config ${deployConfigPath} --project angular-dev-site hosting angular-docs`,
48-
tmpDeployDir,
44+
stagingDir,
4945
);
5046

51-
await rm(tmpDeployDir, {recursive: true});
47+
await rm(stagingDir, {recursive: true});
5248
}
5349

5450
export async function setupRedirect(deployment: Deployment) {
@@ -103,7 +99,7 @@ export async function setupRedirect(deployment: Deployment) {
10399
}
104100

105101
function firebase(cmd: string, cwd?: string) {
106-
spawnSync('npx', `-y [email protected] ${cmd}`.split(' '), {
102+
const {status} = spawnSync('npx', `-y [email protected] ${cmd}`.split(' '), {
107103
cwd,
108104
encoding: 'utf-8',
109105
shell: true,
@@ -113,4 +109,8 @@ function firebase(cmd: string, cwd?: string) {
113109
GOOGLE_APPLICATION_CREDENTIALS: getCredentialFilePath(),
114110
},
115111
});
112+
if (status !== 0) {
113+
console.error('Firebase command failed, see log above for details.');
114+
process.exit(status);
115+
}
116116
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export interface Deployment {
99
to: string;
1010
};
1111
destination?: string;
12+
servingUrl: string;
1213
}
1314

1415
export type Deployments = Map<string, Deployment>;
@@ -31,6 +32,7 @@ export async function getDeployments(): Promise<Deployments> {
3132
docSites.set(branch.name, {
3233
branch: branch.name,
3334
destination: `v${branch.version.major}-angular-dev`,
35+
servingUrl: `https://v${branch.version.major}.angular.dev/`,
3436
});
3537
});
3638

@@ -40,12 +42,14 @@ export async function getDeployments(): Promise<Deployments> {
4042
from: `v${releaseTrains.latest.version.major}-angular-dev`,
4143
to: 'https://angular.dev',
4244
},
45+
servingUrl: 'https://angular.dev/',
4346
destination: 'angular-dev-site',
4447
});
4548

4649
if (releaseTrains.releaseCandidate) {
4750
docSites.set(releaseTrains.next.branchName, {
4851
branch: releaseTrains.next.branchName,
52+
servingUrl: 'https://next.angular.dev/',
4953
});
5054

5155
docSites.set(releaseTrains.releaseCandidate.branchName, {
@@ -55,11 +59,13 @@ export async function getDeployments(): Promise<Deployments> {
5559
from: `v${releaseTrains.releaseCandidate.version.major}-angular-dev`,
5660
to: 'https://next.angular.dev',
5761
},
62+
servingUrl: 'https://next.angular.dev/',
5863
});
5964
} else {
6065
docSites.set(releaseTrains.next.branchName, {
6166
branch: releaseTrains.next.branchName,
6267
destination: 'next-angular-dev',
68+
servingUrl: 'https://next.angular.dev/',
6369
});
6470
}
6571

.angular-github/actions/deploy-docs-site/lib/main.mts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,13 @@ import {getInput, setFailed} from '@actions/core';
22
import {context} from '@actions/github';
33
import {deployToFirebase, setupRedirect} from './deploy.mjs';
44
import {getDeployments} from './deployments.mjs';
5+
import {generateSitemap} from './sitemap.mjs';
56
import {AuthenticatedGitClient, GithubConfig, setConfig} from '@angular/ng-dev';
67
import {githubReleaseTrainReadToken} from './credential.mjs';
8+
import {spawnSync} from 'child_process';
9+
import {cp, mkdtemp} from 'fs/promises';
10+
import {tmpdir} from 'os';
11+
import {join} from 'path';
712

813
const refMatcher = /refs\/heads\/(.*)/;
914

@@ -28,7 +33,11 @@ async function deployDocs() {
2833

2934
const currentBranch = matchedRef[1];
3035
const configPath = getInput('configPath');
31-
const distDir = getInput('distDir');
36+
const stagingDir = await mkdtemp(join(tmpdir(), 'deploy-directory'));
37+
38+
// Copy all files from the distDir into stagingDir and modify the permissions for editing
39+
await cp(getInput('distDir'), stagingDir, {recursive: true});
40+
spawnSync(`chmod 777 -R ${stagingDir}`, {encoding: 'utf-8', shell: true});
3241

3342
const deployment = (await getDeployments()).get(currentBranch);
3443
if (deployment === undefined) {
@@ -57,7 +66,8 @@ async function deployDocs() {
5766
console.log(` To: ${deployment.redirect.to}`);
5867
}
5968

60-
await deployToFirebase(deployment, configPath, distDir);
69+
await generateSitemap(deployment, stagingDir);
70+
await deployToFirebase(deployment, configPath, stagingDir);
6171
await setupRedirect(deployment);
6272
}
6373

0 commit comments

Comments
 (0)