chore(travis): deploy to docs and code when distTag=latest
We now deploy to code.angularjs.org and docs.angularjs.org when we are on the branch which has distTag=latest set in the package.json, i.e. the stable branch. Previously, we deployed to docs only when distTag=latest and the commit was tagged, and to code only on the master branch.
This commit is contained in:
+22
-12
@@ -54,20 +54,32 @@ notifications:
|
||||
jobs:
|
||||
include:
|
||||
- stage: deploy
|
||||
# Don't deploy from PRs.
|
||||
# This is a Travis-specific boolean language: https://docs.travis-ci.com/user/conditional-builds-stages-jobs#Specifying-conditions
|
||||
# The deployment logic for pushed branches is further defined in scripts\travis\build.sh
|
||||
if: type != pull_request
|
||||
env:
|
||||
- JOB=deploy
|
||||
before_script: skip
|
||||
script:
|
||||
- "./scripts/travis/build.sh"
|
||||
# Export the variables into the current process
|
||||
- . ./scripts/travis/build.sh
|
||||
- "echo DEPLOY_DOCS: $DEPLOY_DOCS, DEPLOY_CODE: $DEPLOY_CODE"
|
||||
after_script: skip
|
||||
# Work around the 10min Travis timeout so the code.angularjs firebase+gcs code deploy can complete
|
||||
# Only run the keep_alive once (before_deploy is run for each provider)
|
||||
before_deploy: |
|
||||
function keep_alive() {
|
||||
while true; do
|
||||
echo -en "\a"
|
||||
sleep 5
|
||||
done
|
||||
}
|
||||
keep_alive &
|
||||
if ! [ "$BEFORE_DEPLOY_RUN" ]; then
|
||||
export BEFORE_DEPLOY_RUN=1;
|
||||
|
||||
function keep_alive() {
|
||||
while true; do
|
||||
echo -en "\a"
|
||||
sleep 10
|
||||
done
|
||||
}
|
||||
keep_alive &
|
||||
fi
|
||||
deploy:
|
||||
- provider: firebase
|
||||
# the upload folder for firebase is configured in /firebase.json
|
||||
@@ -77,8 +89,7 @@ jobs:
|
||||
on:
|
||||
repo: angular/angular.js
|
||||
all_branches: true
|
||||
# deploy a new docs version when the commit is tagged on the "latest" npm version
|
||||
condition: $TRAVIS_TAG != '' && $( jq ".distTag" "package.json" | tr -d "\"[:space:]" ) = latest
|
||||
condition: "$DEPLOY_DOCS == true"
|
||||
- provider: gcs
|
||||
skip_cleanup: true
|
||||
access_key_id: GOOGLDB7W2J3LFHICF3R
|
||||
@@ -90,6 +101,5 @@ jobs:
|
||||
on:
|
||||
repo: angular/angular.js
|
||||
all_branches: true
|
||||
# upload the build when the commit is tagged or the branch is "master"
|
||||
condition: $TRAVIS_TAG != '' || ($TRAVIS_PULL_REQUEST = false && $TRAVIS_BRANCH = master)
|
||||
condition: "$DEPLOY_CODE == true"
|
||||
|
||||
|
||||
+5
-1
@@ -63,7 +63,11 @@ module.exports = function(grunt) {
|
||||
NG_VERSION.cdn = versionInfo.cdnVersion;
|
||||
var dist = 'angular-' + NG_VERSION.full;
|
||||
|
||||
var deployVersion = NG_VERSION.isSnapshot ? 'snapshot' : NG_VERSION.full;
|
||||
var deployVersion = NG_VERSION.full;
|
||||
|
||||
if (NG_VERSION.isSnapshot) {
|
||||
deployVersion = NG_VERSION.distTag === 'latest' ? 'snapshot-stable' : 'snapshot';
|
||||
}
|
||||
|
||||
if (versionInfo.cdnVersion == null) {
|
||||
throw new Error('Unable to read CDN version, are you offline or has the CDN not been properly pushed?\n' +
|
||||
|
||||
@@ -169,6 +169,13 @@ function sendStoredFile(request, response) {
|
||||
}
|
||||
}
|
||||
|
||||
const snapshotRegex = /^snapshot(-stable)?\//;
|
||||
|
||||
/**
|
||||
* The build folder contains a zip file that is unique per build.
|
||||
* When a new zip file is uploaded into snapshot or snapshot-stable,
|
||||
* delete the previous zip file.
|
||||
*/
|
||||
function deleteOldSnapshotZip(event) {
|
||||
const object = event.data;
|
||||
|
||||
@@ -179,15 +186,17 @@ function deleteOldSnapshotZip(event) {
|
||||
|
||||
const bucket = gcs.bucket(bucketId);
|
||||
|
||||
if (contentType !== 'application/zip' ||
|
||||
!filePath.startsWith('snapshot/') ||
|
||||
const snapshotFolderMatch = filePath.match(snapshotRegex);
|
||||
|
||||
if (!snapshotFolderMatch ||
|
||||
contentType !== 'application/zip' ||
|
||||
resourceState === 'not_exists' // Deletion event
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
bucket.getFiles({
|
||||
prefix: 'snapshot/',
|
||||
prefix: snapshotFolderMatch[0],
|
||||
delimiter: '/',
|
||||
autoPaginate: false
|
||||
}).then(function(data) {
|
||||
@@ -197,6 +206,8 @@ function deleteOldSnapshotZip(event) {
|
||||
return file.metadata.name !== filePath && file.metadata.contentType === 'application/zip';
|
||||
});
|
||||
|
||||
console.info(`found ${oldZipFiles.length} old zip files to delete`);
|
||||
|
||||
oldZipFiles.forEach(function(file) {
|
||||
file.delete();
|
||||
});
|
||||
|
||||
@@ -6,6 +6,9 @@ This folder contains the Google Firebase scripts for the code.angularjs.org setu
|
||||
firebase.json contains the rewrite rules that route every subdirectory request to the cloud function
|
||||
in functions/index.js that serves the docs from the Firebase Google Cloud Storage bucket.
|
||||
|
||||
functions/index.js also contains a rule that deletes outdated build zip files
|
||||
from the snapshot and snapshot-stable folders when new zip files are uploaded.
|
||||
|
||||
The deployment to the Google Cloud Storage bucket happens automatically via Travis. See the travis.yml
|
||||
file in the repository root.
|
||||
|
||||
|
||||
+27
-6
@@ -46,21 +46,42 @@ case "$JOB" in
|
||||
export USE_JQUERY=1
|
||||
fi
|
||||
|
||||
export TARGET_SPECS="build/docs/ptore2e/**/default_test.js"
|
||||
|
||||
if [[ "$TEST_TARGET" == jquery* ]]; then
|
||||
TARGET_SPECS="build/docs/ptore2e/**/jquery_test.js"
|
||||
else
|
||||
TARGET_SPECS="build/docs/ptore2e/**/default_test.js"
|
||||
fi
|
||||
|
||||
export TARGET_SPECS="test/e2e/tests/**/*.js,$TARGET_SPECS"
|
||||
TARGET_SPECS="test/e2e/tests/**/*.js,$TARGET_SPECS"
|
||||
grunt test:travis-protractor --specs="$TARGET_SPECS"
|
||||
;;
|
||||
"deploy")
|
||||
# we never deploy on Pull requests, so it's safe to skip the build here
|
||||
if [[ "$TRAVIS_PULL_REQUEST" == "false" ]]; then
|
||||
export DEPLOY_DOCS
|
||||
export DEPLOY_CODE
|
||||
|
||||
DIST_TAG=$( jq ".distTag" "package.json" | tr -d "\"[:space:]" )
|
||||
|
||||
# upload docs if the branch distTag from package.json is "latest" (i.e. stable branch)
|
||||
if [[ "$DIST_TAG" == latest ]]; then
|
||||
DEPLOY_DOCS=true
|
||||
else
|
||||
DEPLOY_DOCS=false
|
||||
fi
|
||||
|
||||
# upload the build (code + docs) if ...
|
||||
# the commit is tagged
|
||||
# - or the branch is "master"
|
||||
# - or the branch distTag from package.json is "latest" (i.e. stable branch)
|
||||
if [[ "$TRAVIS_TAG" != '' || "$TRAVIS_BRANCH" == master || "$DIST_TAG" == latest ]]; then
|
||||
DEPLOY_CODE=true
|
||||
else
|
||||
DEPLOY_CODE=false
|
||||
fi
|
||||
|
||||
if [[ "$DEPLOY_DOCS" == true || "$DEPLOY_CODE" == true ]]; then
|
||||
grunt prepareFirebaseDeploy
|
||||
else
|
||||
echo "Skipping build because Travis has been triggered by Pull Request"
|
||||
echo "Skipping deployment build because conditions have not been met."
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
|
||||
Reference in New Issue
Block a user