build(docs-infra): deploy angular.io to new Firebase sites (#39470)

Previously, the documentation for each major Angular version was hosted
on each own Firebase project. This required creating a new project for
each major release and increased the administrative/maintenance cost.

Now that Firebase supports hosting [multiple websites][1] as part of the
same project, we are switching to deploying all major versions to sites
created on `angular-io` project.

This is part of the work needed to prepare angular.io for our
[new versioning/branching process][2] (also tracked in #39366).

[1]: https://firebase.google.com/docs/hosting/multisites
[2]: https://docs.google.com/document/d/197kVillDwx-RZtSVOBtPb4BBIAw0E9RT3q3v6DZkykU

PR Close #39470
This commit is contained in:
George Kalpakas 2020-10-28 20:51:08 +02:00 committed by Joey Perrott
parent 699824a2a5
commit a55a5696a1
2 changed files with 17 additions and 17 deletions

View File

@ -34,7 +34,8 @@ if (require.main === module) {
`Build/deploy mode : ${deploymentInfo.deployEnv}\n` + `Build/deploy mode : ${deploymentInfo.deployEnv}\n` +
`Firebase project : ${deploymentInfo.projectId}\n` + `Firebase project : ${deploymentInfo.projectId}\n` +
`Firebase site : ${deploymentInfo.siteId}\n` + `Firebase site : ${deploymentInfo.siteId}\n` +
`Deployment URLs : ${deploymentInfo.deployedUrl}\n`); `Deployment URLs : ${deploymentInfo.deployedUrl}\n` +
` https://${deploymentInfo.siteId}.web.app/`);
if (!isDryRun) { if (!isDryRun) {
deploy({...inputVars, ...deploymentInfo}); deploy({...inputVars, ...deploymentInfo});
@ -64,14 +65,11 @@ function computeDeploymentInfo(
// The deployment mode is computed based on the branch we are building. // The deployment mode is computed based on the branch we are building.
const currentBranchMajorVersion = computeMajorVersion(currentBranch); const currentBranchMajorVersion = computeMajorVersion(currentBranch);
// Special-case v9, because it is piloting the Firebase hosting "multisites" setup.
// See https://angular-team.atlassian.net/browse/DEV-125 for more info.
const isV9 = currentBranchMajorVersion === 9;
const deploymentInfoPerTarget = { const deploymentInfoPerTarget = {
next: { next: {
deployEnv: 'next', deployEnv: 'next',
projectId: 'aio-staging', projectId: 'angular-io',
siteId: 'aio-staging', siteId: 'next-angular-io-site',
deployedUrl: 'https://next.angular.io/', deployedUrl: 'https://next.angular.io/',
}, },
rc: { rc: {
@ -83,13 +81,13 @@ function computeDeploymentInfo(
stable: { stable: {
deployEnv: 'stable', deployEnv: 'stable',
projectId: 'angular-io', projectId: 'angular-io',
siteId: 'angular-io', siteId: `v${currentBranchMajorVersion}-angular-io-site`,
deployedUrl: 'https://angular.io/', deployedUrl: 'https://angular.io/',
}, },
archive: { archive: {
deployEnv: 'archive', deployEnv: 'archive',
projectId: isV9 ? 'aio-staging' : `v${currentBranchMajorVersion}-angular-io`, projectId: 'angular-io',
siteId: isV9 ? 'v9-angular-io' : `v${currentBranchMajorVersion}-angular-io`, siteId: `v${currentBranchMajorVersion}-angular-io-site`,
deployedUrl: `https://v${currentBranchMajorVersion}.angular.io/`, deployedUrl: `https://v${currentBranchMajorVersion}.angular.io/`,
}, },
}; };

View File

@ -45,8 +45,8 @@ describe('deploy-to-firebase:', () => {
CI_COMMIT: getLatestCommit('master'), CI_COMMIT: getLatestCommit('master'),
}))).toEqual({ }))).toEqual({
deployEnv: 'next', deployEnv: 'next',
projectId: 'aio-staging', projectId: 'angular-io',
siteId: 'aio-staging', siteId: 'next-angular-io-site',
deployedUrl: 'https://next.angular.io/', deployedUrl: 'https://next.angular.io/',
}); });
}); });
@ -77,7 +77,7 @@ describe('deploy-to-firebase:', () => {
}))).toEqual({ }))).toEqual({
deployEnv: 'stable', deployEnv: 'stable',
projectId: 'angular-io', projectId: 'angular-io',
siteId: 'angular-io', siteId: 'v4-angular-io-site',
deployedUrl: 'https://angular.io/', deployedUrl: 'https://angular.io/',
}); });
}); });
@ -108,13 +108,15 @@ describe('deploy-to-firebase:', () => {
CI_COMMIT: getLatestCommit('2.4.x'), CI_COMMIT: getLatestCommit('2.4.x'),
}))).toEqual({ }))).toEqual({
deployEnv: 'archive', deployEnv: 'archive',
projectId: 'v2-angular-io', projectId: 'angular-io',
siteId: 'v2-angular-io', siteId: 'v2-angular-io-site',
deployedUrl: 'https://v2.angular.io/', deployedUrl: 'https://v2.angular.io/',
}); });
}); });
it('archive - v9-angular-io multisite special case - deploy success', () => { // v9 used to be special-cased, because it was piloting the Firebase hosting "multisites" setup.
// See https://angular-team.atlassian.net/browse/DEV-125 for more info.
it('archive - deploy success (no special case for v9)', () => {
expect(computeDeploymentInfo(computeInputVars({ expect(computeDeploymentInfo(computeInputVars({
CI_REPO_OWNER: 'angular', CI_REPO_OWNER: 'angular',
CI_REPO_NAME: 'angular', CI_REPO_NAME: 'angular',
@ -124,8 +126,8 @@ describe('deploy-to-firebase:', () => {
CI_COMMIT: getLatestCommit('9.1.x'), CI_COMMIT: getLatestCommit('9.1.x'),
}))).toEqual({ }))).toEqual({
deployEnv: 'archive', deployEnv: 'archive',
projectId: 'aio-staging', projectId: 'angular-io',
siteId: 'v9-angular-io', siteId: 'v9-angular-io-site',
deployedUrl: 'https://v9.angular.io/', deployedUrl: 'https://v9.angular.io/',
}); });
}); });