devops: support beta deployment for Trace viewer (#10201)

Trace Viewer will have 3 deployments:
- Stable: https://trace.playwright.dev
- Beta (from release branch): https://trace.playwright.dev/beta
- Next (from master branch): https://trace.playwright.dev/next
This commit is contained in:
Andrey Lushnikov 2021-11-09 17:21:51 -08:00 committed by GitHub
parent 56521e2a49
commit 7af0dc178b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 23 deletions

View File

@ -66,7 +66,13 @@ jobs:
with:
node-version: 16
- run: npm i -g npm@7
- name: Deploy
run: bash utils/build/deploy-trace-viewer.sh canary
env:
- name: Deploy Canary
run: bash utils/build/deploy-trace-viewer.sh --canary
if: contains(github.ref, 'master')
env:
GH_SERVICE_ACCOUNT_TOKEN: ${{ secrets.GH_SERVICE_ACCOUNT_TOKEN }}
- name: Deploy BETA
run: bash utils/build/deploy-trace-viewer.sh --beta
if: contains(github.ref, 'release')
env:
GH_SERVICE_ACCOUNT_TOKEN: ${{ secrets.GH_SERVICE_ACCOUNT_TOKEN }}

View File

@ -72,7 +72,7 @@ jobs:
with:
node-version: 16
- run: npm i -g npm@7
- name: Deploy
run: bash utils/build/deploy-trace-viewer.sh production
- name: Deploy Stable
run: bash utils/build/deploy-trace-viewer.sh --stable
env:
GH_SERVICE_ACCOUNT_TOKEN: ${{ secrets.GH_SERVICE_ACCOUNT_TOKEN }}

View File

@ -3,7 +3,7 @@
set -e
if [[ ($1 == '--help') || ($1 == '-h') ]]; then
echo "usage: $(basename $0) {canary,production}"
echo "usage: $(basename $0) {--stable,--beta,--canary}"
echo
echo "Build the Trace Viewer and push it to the GitHub repository."
echo
@ -20,7 +20,7 @@ if [[ -z "${GH_SERVICE_ACCOUNT_TOKEN}" ]]; then
exit 1
fi
ENVIRONMENT="$1"
RELEASE_CHANNEL="$1"
# 1. Install dependencies and build the Trace Viewer
npm ci
@ -32,31 +32,31 @@ git config --global user.email 41898282+github-actions[bot]@users.noreply.github
git clone "https://${GH_SERVICE_ACCOUNT_TOKEN}@github.com/microsoft/playwright-trace.git" playwright-trace
# 3. Copy the built Trace Viewer to the repository
if [[ "${ENVIRONMENT}" == "production" ]]; then
# 3.1 make a copy of the current next/ folder
if [[ -d "playwright-trace/docs/next" ]]; then
cp -r playwright-trace/docs/next .next-previous
fi
# 3.2 Clean it
if [[ "${RELEASE_CHANNEL}" == "--stable" ]]; then
rm -rf playwright-trace/docs/
mkdir playwright-trace/docs/
# 3.3 Copy the old next/ back into the folder
if [[ -d ".next-previous/" ]]; then
mv .next-previous/ playwright-trace/docs/next/
fi
# 3.4 Copy the new production over
cp -r packages/playwright-core/lib/webpack/traceViewer/* playwright-trace/docs/
echo "Updated production version"
elif [[ "${ENVIRONMENT}" == "canary" ]]; then
# Restore CNAME, beta/ & next/ branches.
cd playwright-trace/
git checkout docs/beta
git checkout docs/next
git checkout docs/CNAME
cd -
echo "Updated stable version"
elif [[ "${RELEASE_CHANNEL}" == "--canary" ]]; then
rm -rf playwright-trace/docs/next/
cp -r packages/playwright-core/lib/webpack/traceViewer/ playwright-trace/docs/next/
echo "Updated canary version"
elif [[ "${RELEASE_CHANNEL}" == "--beta" ]]; then
rm -rf playwright-trace/docs/beta/
cp -r packages/playwright-core/lib/webpack/traceViewer/ playwright-trace/docs/beta/
echo "Updated beta version"
else
echo "ERROR: unknown environment - ${ENVIRONMENT}"
echo "ERROR: unknown environment - ${RELEASE_CHANNEL}"
exit 1
fi
# CNAME needs to be located inside the served docs/ folder for GitHub Pages
cp playwright-trace/CNAME playwright-trace/docs/CNAME
# 4. Commit and push the changes
cd playwright-trace/