ci: fix AIO deployment to multiple Firebase sites (#39948)

Since #39853, it is possible to deploy to multiple Firebase sites from a
single branch. In order to deploy to a site, we need to associate an
alias (`aio`) with a site. This is done via the `firebase target:apply`
command. However, when the command is called multiple times, it
associates the alias with many sites, which subsequently fails during
deployment ([example failure][1]), since the `firebase deploy` command
does not know what site to deploy to.

This commit fixes the deployment script by ensuring that any previous
association with the `aio` alias is cleared (via the
`firebase target:clear` command) before associating it with a new site.

[1]: https://circleci.com/gh/angular/angular/871020

PR Close #39948
This commit is contained in:
George Kalpakas 2020-12-03 15:50:00 +02:00 committed by Misko Hevery
parent aa8bd733fa
commit f01c713ee2
1 changed files with 5 additions and 5 deletions

View File

@ -250,11 +250,11 @@ function deploy(data) {
preDeployActions.forEach(fn => fn(data));
console.log('\n\n\n==== Deploy AIO to Firebase hosting. ====\n');
yarn(`firebase use "${projectId}" --token "${firebaseToken}"`);
yarn(`firebase target:apply hosting aio "${siteId}" --token "${firebaseToken}"`);
yarn(
`firebase deploy --only hosting:aio --message "Commit: ${currentCommit}" --non-interactive ` +
`--token "${firebaseToken}"`);
const firebase = cmd => yarn(`firebase ${cmd} --token "${firebaseToken}"`);
firebase(`use "${projectId}"`);
firebase('target:clear hosting aio');
firebase(`target:apply hosting aio "${siteId}"`);
firebase(`deploy --only hosting:aio --message "Commit: ${currentCommit}" --non-interactive`);
console.log('\n\n\n==== Run post-deploy actions. ====\n');
postDeployActions.forEach(fn => fn(data));