
committed by
Alex Rickabaugh

parent
9b8a244a15
commit
38d626a3fa
@ -3,33 +3,39 @@
|
||||
# WARNING: CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN should NOT be printed.
|
||||
set +x -eu -o pipefail
|
||||
|
||||
# Only deploy if this not a PR. PRs are deployed early in `build.sh`.
|
||||
# Do not deploy if we are running in a fork.
|
||||
if [[ "$CI_REPO_OWNER/$CI_REPO_NAME" != "angular/angular" ]]; then
|
||||
echo "Skipping deploy because this is not angular/angular."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Do not deploy if this is a PR. PRs are deployed in the `aio_preview` CircleCI job.
|
||||
if [[ $CI_PULL_REQUEST != "false" ]]; then
|
||||
echo "Skipping deploy because this is a PR build."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Do not deploy if the current commit is not the latest on its branch.
|
||||
readonly LATEST_COMMIT=$(git ls-remote origin $CI_BRANCH | cut -c1-40)
|
||||
if [[ $CI_COMMIT != $LATEST_COMMIT ]]; then
|
||||
echo "Skipping deploy because $CI_COMMIT is not the latest commit ($LATEST_COMMIT)."
|
||||
readonly latestCommit=$(git ls-remote origin $CI_BRANCH | cut -c1-40)
|
||||
if [[ $CI_COMMIT != $latestCommit ]]; then
|
||||
echo "Skipping deploy because $CI_COMMIT is not the latest commit ($latestCommit)."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# The deployment mode is computed based on the branch we are building
|
||||
if [[ $CI_BRANCH == master ]]; then
|
||||
readonly deployEnv=next
|
||||
elif [[ $CI_BRANCH == $STABLE_BRANCH ]]; then
|
||||
elif [[ $CI_BRANCH == $CI_STABLE_BRANCH ]]; then
|
||||
readonly deployEnv=stable
|
||||
else
|
||||
# Extract the major versions from the branches, e.g. the 4 from 4.3.x
|
||||
readonly majorVersion=${CI_BRANCH%%.*}
|
||||
readonly majorVersionStable=${STABLE_BRANCH%%.*}
|
||||
readonly majorVersionStable=${CI_STABLE_BRANCH%%.*}
|
||||
|
||||
# Do not deploy if the major version is not less than the stable branch major version
|
||||
if [[ !( "$majorVersion" < "$majorVersionStable" ) ]]; then
|
||||
echo "Skipping deploy of branch \"$CI_BRANCH\" to firebase."
|
||||
echo "We only deploy archive branches with the major version less than the stable branch: \"$STABLE_BRANCH\""
|
||||
echo "We only deploy archive branches with the major version less than the stable branch: \"$CI_STABLE_BRANCH\""
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
set +x -eu -o pipefail
|
||||
|
||||
readonly deployToFirebaseDryRun="`dirname $0`/deploy-to-firebase.sh --dry-run"
|
||||
|
||||
function check {
|
||||
if [[ $1 == $2 ]]; then
|
||||
echo Pass
|
||||
@ -14,11 +16,38 @@ function check {
|
||||
exit 1
|
||||
}
|
||||
|
||||
(
|
||||
echo ===== master - skip deploy - not angular
|
||||
actual=$(
|
||||
export BASH_ENV=/dev/null
|
||||
export CI_REPO_OWNER=angular
|
||||
export CI_REPO_NAME=notangular
|
||||
$deployToFirebaseDryRun
|
||||
)
|
||||
expected="Skipping deploy because this is not angular/angular."
|
||||
check "$actual" "$expected"
|
||||
)
|
||||
|
||||
(
|
||||
echo ===== master - skip deploy - angular fork
|
||||
actual=$(
|
||||
export BASH_ENV=/dev/null
|
||||
export CI_REPO_OWNER=notangular
|
||||
export CI_REPO_NAME=angular
|
||||
$deployToFirebaseDryRun
|
||||
)
|
||||
expected="Skipping deploy because this is not angular/angular."
|
||||
check "$actual" "$expected"
|
||||
)
|
||||
|
||||
(
|
||||
echo ===== master - skip deploy - pull request
|
||||
actual=$(
|
||||
export BASH_ENV=/dev/null
|
||||
export CI_REPO_OWNER=angular
|
||||
export CI_REPO_NAME=angular
|
||||
export CI_PULL_REQUEST=true
|
||||
`dirname $0`/deploy-to-firebase.sh --dry-run
|
||||
$deployToFirebaseDryRun
|
||||
)
|
||||
expected="Skipping deploy because this is a PR build."
|
||||
check "$actual" "$expected"
|
||||
@ -27,11 +56,14 @@ function check {
|
||||
(
|
||||
echo ===== master - deploy success
|
||||
actual=$(
|
||||
export BASH_ENV=/dev/null
|
||||
export CI_REPO_OWNER=angular
|
||||
export CI_REPO_NAME=angular
|
||||
export CI_PULL_REQUEST=false
|
||||
export CI_BRANCH=master
|
||||
export CI_COMMIT=$(git ls-remote origin master | cut -c-40)
|
||||
export CI_COMMIT=$(git ls-remote origin master | cut -c1-40)
|
||||
export CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN=XXXXX
|
||||
`dirname $0`/deploy-to-firebase.sh --dry-run
|
||||
$deployToFirebaseDryRun
|
||||
)
|
||||
expected="Git branch : master
|
||||
Build/deploy mode : next
|
||||
@ -43,10 +75,13 @@ Deployment URL : https://next.angular.io/"
|
||||
(
|
||||
echo ===== master - skip deploy - commit not HEAD
|
||||
actual=$(
|
||||
export BASH_ENV=/dev/null
|
||||
export CI_REPO_OWNER=angular
|
||||
export CI_REPO_NAME=angular
|
||||
export CI_PULL_REQUEST=false
|
||||
export CI_BRANCH=master
|
||||
export CI_COMMIT=DUMMY_TEST_COMMIT
|
||||
`dirname $0`/deploy-to-firebase.sh --dry-run
|
||||
$deployToFirebaseDryRun
|
||||
)
|
||||
expected="Skipping deploy because DUMMY_TEST_COMMIT is not the latest commit ($(git ls-remote origin master | cut -c1-40))."
|
||||
check "$actual" "$expected"
|
||||
@ -55,12 +90,15 @@ Deployment URL : https://next.angular.io/"
|
||||
(
|
||||
echo ===== stable - deploy success
|
||||
actual=$(
|
||||
export BASH_ENV=/dev/null
|
||||
export CI_REPO_OWNER=angular
|
||||
export CI_REPO_NAME=angular
|
||||
export CI_PULL_REQUEST=false
|
||||
export CI_BRANCH=4.3.x
|
||||
export STABLE_BRANCH=4.3.x
|
||||
export CI_COMMIT=$(git ls-remote origin 4.3.x | cut -c-40)
|
||||
export CI_STABLE_BRANCH=4.3.x
|
||||
export CI_COMMIT=$(git ls-remote origin 4.3.x | cut -c1-40)
|
||||
export CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN=XXXXX
|
||||
`dirname $0`/deploy-to-firebase.sh --dry-run
|
||||
$deployToFirebaseDryRun
|
||||
)
|
||||
expected="Git branch : 4.3.x
|
||||
Build/deploy mode : stable
|
||||
@ -72,11 +110,14 @@ Deployment URL : https://angular.io/"
|
||||
(
|
||||
echo ===== stable - skip deploy - commit not HEAD
|
||||
actual=$(
|
||||
export BASH_ENV=/dev/null
|
||||
export CI_REPO_OWNER=angular
|
||||
export CI_REPO_NAME=angular
|
||||
export CI_PULL_REQUEST=false
|
||||
export CI_BRANCH=4.3.x
|
||||
export STABLE_BRANCH=4.3.x
|
||||
export CI_STABLE_BRANCH=4.3.x
|
||||
export CI_COMMIT=DUMMY_TEST_COMMIT
|
||||
`dirname $0`/deploy-to-firebase.sh --dry-run
|
||||
$deployToFirebaseDryRun
|
||||
)
|
||||
expected="Skipping deploy because DUMMY_TEST_COMMIT is not the latest commit ($(git ls-remote origin 4.3.x | cut -c1-40))."
|
||||
check "$actual" "$expected"
|
||||
@ -85,12 +126,15 @@ Deployment URL : https://angular.io/"
|
||||
(
|
||||
echo ===== archive - deploy success
|
||||
actual=$(
|
||||
export BASH_ENV=/dev/null
|
||||
export CI_REPO_OWNER=angular
|
||||
export CI_REPO_NAME=angular
|
||||
export CI_PULL_REQUEST=false
|
||||
export CI_BRANCH=2.4.x
|
||||
export STABLE_BRANCH=4.3.x
|
||||
export CI_COMMIT=$(git ls-remote origin 2.4.x | cut -c-40)
|
||||
export CI_STABLE_BRANCH=4.3.x
|
||||
export CI_COMMIT=$(git ls-remote origin 2.4.x | cut -c1-40)
|
||||
export CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN=XXXXX
|
||||
`dirname $0`/deploy-to-firebase.sh --dry-run
|
||||
$deployToFirebaseDryRun
|
||||
)
|
||||
expected="Git branch : 2.4.x
|
||||
Build/deploy mode : archive
|
||||
@ -102,12 +146,15 @@ Deployment URL : https://v2.angular.io/"
|
||||
(
|
||||
echo ===== archive - skip deploy - commit not HEAD
|
||||
actual=$(
|
||||
export BASH_ENV=/dev/null
|
||||
export CI_REPO_OWNER=angular
|
||||
export CI_REPO_NAME=angular
|
||||
export CI_PULL_REQUEST=false
|
||||
export CI_BRANCH=2.4.x
|
||||
export STABLE_BRANCH=4.3.x
|
||||
export CI_STABLE_BRANCH=4.3.x
|
||||
export CI_COMMIT=DUMMY_TEST_COMMIT
|
||||
export CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN=XXXXX
|
||||
`dirname $0`/deploy-to-firebase.sh --dry-run
|
||||
$deployToFirebaseDryRun
|
||||
)
|
||||
expected="Skipping deploy because DUMMY_TEST_COMMIT is not the latest commit ($(git ls-remote origin 2.4.x | cut -c1-40))."
|
||||
check "$actual" "$expected"
|
||||
@ -116,12 +163,15 @@ Deployment URL : https://v2.angular.io/"
|
||||
(
|
||||
echo ===== archive - skip deploy - major version too high, lower minor
|
||||
actual=$(
|
||||
export BASH_ENV=/dev/null
|
||||
export CI_REPO_OWNER=angular
|
||||
export CI_REPO_NAME=angular
|
||||
export CI_PULL_REQUEST=false
|
||||
export CI_BRANCH=2.1.x
|
||||
export STABLE_BRANCH=2.2.x
|
||||
export CI_STABLE_BRANCH=2.2.x
|
||||
export CI_COMMIT=$(git ls-remote origin 2.1.x | cut -c-40)
|
||||
export CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN=XXXXX
|
||||
`dirname $0`/deploy-to-firebase.sh --dry-run
|
||||
$deployToFirebaseDryRun
|
||||
)
|
||||
expected="Skipping deploy of branch \"2.1.x\" to firebase.
|
||||
We only deploy archive branches with the major version less than the stable branch: \"2.2.x\""
|
||||
@ -131,12 +181,15 @@ We only deploy archive branches with the major version less than the stable bran
|
||||
(
|
||||
echo ===== archive - skip deploy - major version too high, higher minor
|
||||
actual=$(
|
||||
export BASH_ENV=/dev/null
|
||||
export CI_REPO_OWNER=angular
|
||||
export CI_REPO_NAME=angular
|
||||
export CI_PULL_REQUEST=false
|
||||
export CI_BRANCH=2.4.x
|
||||
export STABLE_BRANCH=2.2.x
|
||||
export CI_STABLE_BRANCH=2.2.x
|
||||
export CI_COMMIT=$(git ls-remote origin 2.4.x | cut -c-40)
|
||||
export CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN=XXXXX
|
||||
`dirname $0`/deploy-to-firebase.sh --dry-run
|
||||
$deployToFirebaseDryRun
|
||||
)
|
||||
expected="Skipping deploy of branch \"2.4.x\" to firebase.
|
||||
We only deploy archive branches with the major version less than the stable branch: \"2.2.x\""
|
||||
@ -146,12 +199,15 @@ We only deploy archive branches with the major version less than the stable bran
|
||||
(
|
||||
echo ===== archive - skip deploy - minor version too low
|
||||
actual=$(
|
||||
export BASH_ENV=/dev/null
|
||||
export CI_REPO_OWNER=angular
|
||||
export CI_REPO_NAME=angular
|
||||
export CI_PULL_REQUEST=false
|
||||
export CI_BRANCH=2.1.x
|
||||
export STABLE_BRANCH=4.3.x
|
||||
export CI_STABLE_BRANCH=4.3.x
|
||||
export CI_COMMIT=$(git ls-remote origin 2.1.x | cut -c-40)
|
||||
export CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN=XXXXX
|
||||
`dirname $0`/deploy-to-firebase.sh --dry-run
|
||||
$deployToFirebaseDryRun
|
||||
)
|
||||
expected="Skipping deploy of branch \"2.1.x\" to firebase.
|
||||
There is a more recent branch with the same major version: \"2.4.x\""
|
||||
|
Reference in New Issue
Block a user