mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
build: add dashboard firebase functions (#4806)
* build: add dashboard firebase functions * Adds a new folder for the dashboard project that for now only contains firebase functions. * The firebase functions will be used to securely make API calls to the Github API (e.g payload status) * Functions will be automatically deployed as same as screenshot functions. * Address feedback
This commit is contained in:
committed by
mmalerba
parent
f169152638
commit
964033ce8d
@@ -1,17 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Go to the project root directory
|
||||
cd $(dirname ${0})/../..
|
||||
|
||||
# Install node modules for screenshot functions. Firebase CLI needs to execute the functions
|
||||
# before it can collect all functions and deploy them.
|
||||
(cd tools/screenshot-test/functions; npm install)
|
||||
|
||||
if [ -z ${MATERIAL2_SCREENSHOT_ACCESS_TOKEN} ]; then
|
||||
echo "Error: No access token for firebase specified." \
|
||||
"Please set the environment variable 'MATERIAL2_SCREENSHOT_ACCESS_TOKEN'."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Deploy the screenshot functions to Firebase
|
||||
$(npm bin)/firebase deploy --only functions --token ${MATERIAL2_SCREENSHOT_ACCESS_TOKEN}
|
||||
@@ -1,80 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Script to publish the build artifacts to a GitHub repository.
|
||||
# Builds will be automatically published once new changes are made to the repository.
|
||||
|
||||
set -e -o pipefail
|
||||
|
||||
# Go to the project root directory
|
||||
cd $(dirname ${0})/../..
|
||||
|
||||
# Material packages that need to published.
|
||||
PACKAGES=(cdk material)
|
||||
REPOSITORIES=(cdk-builds material2-builds)
|
||||
|
||||
# Command line arguments.
|
||||
COMMAND_ARGS=${*}
|
||||
|
||||
# Function to publish artifacts of a package to Github.
|
||||
# @param ${1} Name of the package
|
||||
# @param ${2} Repository name of the package.
|
||||
publishPackage() {
|
||||
packageName=${1}
|
||||
packageRepo=${2}
|
||||
|
||||
buildDir="dist/releases/${packageName}"
|
||||
buildVersion=$(sed -nE 's/^\s*"version": "(.*?)",$/\1/p' package.json)
|
||||
|
||||
commitSha=$(git rev-parse --short HEAD)
|
||||
commitAuthorName=$(git --no-pager show -s --format='%an' HEAD)
|
||||
commitAuthorEmail=$(git --no-pager show -s --format='%ae' HEAD)
|
||||
commitMessage=$(git log --oneline -n 1)
|
||||
|
||||
repoUrl="https://github.com/angular/${packageRepo}.git"
|
||||
repoDir="tmp/${packageRepo}"
|
||||
|
||||
if [[ ! ${COMMAND_ARGS} == *--no-build* ]]; then
|
||||
# Create a release of the current repository.
|
||||
$(npm bin)/gulp ${packageName}:build-release:clean
|
||||
fi
|
||||
|
||||
# Prepare cloning the builds repository
|
||||
rm -rf ${repoDir}
|
||||
mkdir -p ${repoDir}
|
||||
|
||||
# Clone the repository
|
||||
git clone ${repoUrl} ${repoDir}
|
||||
|
||||
# Copy the build files to the repository
|
||||
rm -rf ${repoDir}/*
|
||||
cp -r ${buildDir}/* ${repoDir}
|
||||
|
||||
# Create the build commit and push the changes to the repository.
|
||||
cd ${repoDir}
|
||||
|
||||
# Update the package.json version to include the current commit SHA.
|
||||
sed -i "s/${buildVersion}/${buildVersion}-${commitSha}/g" package.json
|
||||
|
||||
# Prepare Git for pushing the artifacts to the repository.
|
||||
git config user.name "${commitAuthorName}"
|
||||
git config user.email "${commitAuthorEmail}"
|
||||
git config credential.helper "store --file=.git/credentials"
|
||||
|
||||
echo "https://${MATERIAL2_BUILDS_TOKEN}:@github.com" > .git/credentials
|
||||
|
||||
git add -A
|
||||
git commit -m "${commitMessage}"
|
||||
git tag "${buildVersion}-${commitSha}"
|
||||
git push origin master --tags
|
||||
|
||||
echo "Published artifacts for ${packageName} package."
|
||||
}
|
||||
|
||||
for ((i = 0; i < ${#PACKAGES[@]}; i++)); do
|
||||
packageName=${PACKAGES[${i}]}
|
||||
packageRepo=${REPOSITORIES[${i}]}
|
||||
|
||||
# Publish artifacts of the current package. Run publishing in a sub-shell to avoid working
|
||||
# directory changes.
|
||||
(publishPackage ${packageName} ${packageRepo})
|
||||
done
|
||||
@@ -1,86 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Publish material2 docs assets to the material2-docs-content repo
|
||||
# material.angular.io will pull from this assets repo to get the latest docs
|
||||
|
||||
cd "$(dirname $0)/../../"
|
||||
|
||||
docsPath="./dist/docs"
|
||||
packagePath="./dist/releases/material-examples"
|
||||
repoPath="/tmp/material2-docs-content"
|
||||
repoUrl="https://github.com/angular/material2-docs-content"
|
||||
examplesSource="./dist/docs/examples"
|
||||
|
||||
if [[ ! ${*} == *--no-build* ]]; then
|
||||
$(npm bin)/gulp material-examples:build-release:clean
|
||||
$(npm bin)/gulp docs
|
||||
fi
|
||||
|
||||
# Get git meta info for commit
|
||||
commitSha="$(git rev-parse --short HEAD)"
|
||||
commitAuthorName="$(git --no-pager show -s --format='%an' HEAD)"
|
||||
commitAuthorEmail="$(git --no-pager show -s --format='%ae' HEAD)"
|
||||
commitMessage="$(git log --oneline -n 1)"
|
||||
|
||||
# create directory and clone test repo
|
||||
rm -rf $repoPath
|
||||
mkdir -p $repoPath
|
||||
git clone $repoUrl $repoPath
|
||||
|
||||
# Clean out repo directory and copy contents of dist/docs into it
|
||||
rm -rf $repoPath/*
|
||||
|
||||
# Create folders that will contain docs content files.
|
||||
mkdir $repoPath/{overview,guides,api,examples,plunker,examples-package}
|
||||
|
||||
# Copy api files over to $repoPath/api
|
||||
cp -r $docsPath/api/* $repoPath/api
|
||||
|
||||
# Copy the material-examples package to the docs content repository.
|
||||
cp -r $packagePath/* $repoPath/examples-package
|
||||
|
||||
# Flatten the markdown docs structure and move it into $repoPath/overview
|
||||
overviewFiles=$docsPath/markdown/
|
||||
for filename in $overviewFiles*
|
||||
do
|
||||
if [ -d $filename ]; then
|
||||
for _ in $filename/*
|
||||
do
|
||||
markdownFile=${filename#$overviewFiles}.html
|
||||
# Filename should be same as folder name with .html extension
|
||||
if [ -e $filename/$markdownFile ]; then
|
||||
cp -r $filename/$markdownFile $repoPath/overview/
|
||||
fi
|
||||
done
|
||||
fi
|
||||
done
|
||||
|
||||
# Copy guide files over to $repoPath/guides
|
||||
for filename in $overviewFiles*
|
||||
do
|
||||
if [ -f $filename ]; then
|
||||
cp -r $filename $repoPath/guides
|
||||
fi
|
||||
done
|
||||
|
||||
# Copy highlighted examples into $repoPath
|
||||
cp -r $examplesSource/* $repoPath/examples
|
||||
|
||||
# Copy example plunker assets
|
||||
cp -r $docsPath/plunker/* $repoPath/plunker
|
||||
|
||||
# Copies assets over to the docs-content repository.
|
||||
cp LICENSE $repoPath/
|
||||
|
||||
# Push content to repo
|
||||
cd $repoPath
|
||||
git config user.name "$commitAuthorName"
|
||||
git config user.email "$commitAuthorEmail"
|
||||
git config credential.helper "store --file=.git/credentials"
|
||||
|
||||
echo "https://${MATERIAL2_DOCS_CONTENT_TOKEN}:@github.com" > .git/credentials
|
||||
|
||||
git add -A
|
||||
git commit -m "$commitMessage"
|
||||
git tag "$commitSha"
|
||||
git push origin master --tags
|
||||
Reference in New Issue
Block a user