From 7af0dc178b8ddc212df18f4c423a3cdb60e94b0e Mon Sep 17 00:00:00 2001 From: Andrey Lushnikov Date: Tue, 9 Nov 2021 17:21:51 -0800 Subject: [PATCH] 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 --- .github/workflows/publish_canary.yml | 12 ++++++--- .github/workflows/publish_release.yml | 4 +-- utils/build/deploy-trace-viewer.sh | 36 +++++++++++++-------------- 3 files changed, 29 insertions(+), 23 deletions(-) diff --git a/.github/workflows/publish_canary.yml b/.github/workflows/publish_canary.yml index 781b898bd4..c127951888 100644 --- a/.github/workflows/publish_canary.yml +++ b/.github/workflows/publish_canary.yml @@ -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 }} diff --git a/.github/workflows/publish_release.yml b/.github/workflows/publish_release.yml index 927282188c..3feab744f8 100644 --- a/.github/workflows/publish_release.yml +++ b/.github/workflows/publish_release.yml @@ -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 }} diff --git a/utils/build/deploy-trace-viewer.sh b/utils/build/deploy-trace-viewer.sh index d9f60774b8..94ffe926dc 100755 --- a/utils/build/deploy-trace-viewer.sh +++ b/utils/build/deploy-trace-viewer.sh @@ -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/