mirror of
				https://github.com/microsoft/playwright.git
				synced 2025-06-26 21:40:17 +00:00 
			
		
		
		
	 6e78dcb7dc
			
		
	
	
		6e78dcb7dc
		
			
		
	
	
	
	
		
			
			Although very common, bash is not guaranteed to be located at `/bin/bash`. NixOS is an example of this. More commonly, `/bin/bash` can be quite out of date. An example of this is MacOS's version of `bash`. This realistically won't affect Playwright but it's worth noting. You can technically update MacOS's system version of bash but you need elevated permissions to do so. By using `/usr/bin/env bash` instead of `/bin/bash` we can execute Playwright's bash scripts in like NixOS and generally improve the selection behaviour for bash in other systems too. Some discussion of why it's worth favouring `/usr/bin/env bash` over `/bin/bash`: - Discusses `/bin/bash` missing in NixOS: https://discourse.nixos.org/t/add-bin-bash-to-avoid-unnecessary-pain/5673 - Some general commentary on why `/usr/bin/env bash` is favoured: https://askubuntu.com/a/1402721 - Points out how old bash is in MacOS: https://itnext.io/upgrading-bash-on-macos-7138bd1066ba Improves situation at #5501
		
			
				
	
	
		
			73 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			73 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
| #!/usr/bin/env bash
 | |
| 
 | |
| set -e
 | |
| 
 | |
| if [[ ($1 == '--help') || ($1 == '-h') ]]; then
 | |
|   echo "usage: $(basename $0) {--stable,--beta,--canary}"
 | |
|   echo
 | |
|   echo "Build the Trace Viewer and push it to the GitHub repository."
 | |
|   echo
 | |
|   echo "NOTE: the following env variables are required:"
 | |
|   echo "  GH_SERVICE_ACCOUNT_TOKEN     GitHub token with access to the microsoft/trace.playwright.dev repository"
 | |
|   echo "  GITHUB_SHA                   GitHub commit SHA - injected via GitHub Actions"
 | |
|   echo
 | |
|   echo "This script is designed to get executed via GitHub Actions"
 | |
|   exit 0
 | |
| fi
 | |
| 
 | |
| if [[ -z "${GH_SERVICE_ACCOUNT_TOKEN}" ]]; then
 | |
|   echo "NOTE: GH_SERVICE_ACCOUNT_TOKEN environment variable is required"
 | |
|   exit 1
 | |
| fi
 | |
| 
 | |
| RELEASE_CHANNEL="$1"
 | |
| 
 | |
| # 1. Install dependencies and build the Trace Viewer
 | |
| npm ci
 | |
| npm run build
 | |
| 
 | |
| # 2. Configure Git and clone the Trace Viewer repository
 | |
| git config --global user.name github-actions
 | |
| git config --global user.email 41898282+github-actions[bot]@users.noreply.github.com
 | |
| git clone "https://${GH_SERVICE_ACCOUNT_TOKEN}@github.com/microsoft/trace.playwright.dev.git" trace.playwright.dev
 | |
| 
 | |
| # 3. Copy the built Trace Viewer to the repository
 | |
| if [[ "${RELEASE_CHANNEL}" == "--stable" ]]; then
 | |
|   rm -rf trace.playwright.dev/docs/
 | |
|   mkdir trace.playwright.dev/docs/
 | |
|   cp -r packages/playwright-core/lib/webpack/traceViewer/* trace.playwright.dev/docs/
 | |
| 
 | |
|   # Restore CNAME, beta/ & next/ branches.
 | |
|   cd trace.playwright.dev/
 | |
|   git checkout docs/beta
 | |
|   git checkout docs/next
 | |
|   git checkout docs/CNAME
 | |
|   cd -
 | |
| 
 | |
|   echo "Updated stable version"
 | |
| elif [[ "${RELEASE_CHANNEL}" == "--canary" ]]; then
 | |
|   rm -rf trace.playwright.dev/docs/next/
 | |
|   cp -r packages/playwright-core/lib/webpack/traceViewer/ trace.playwright.dev/docs/next/
 | |
|   echo "Updated canary version"
 | |
| elif [[ "${RELEASE_CHANNEL}" == "--beta" ]]; then
 | |
|   rm -rf trace.playwright.dev/docs/beta/
 | |
|   cp -r packages/playwright-core/lib/webpack/traceViewer/ trace.playwright.dev/docs/beta/
 | |
|   echo "Updated beta version"
 | |
| else
 | |
|   echo "ERROR: unknown environment - ${RELEASE_CHANNEL}"
 | |
|   exit 1
 | |
| fi
 | |
| 
 | |
| # 4. Commit and push the changes
 | |
| cd trace.playwright.dev/
 | |
| git add .
 | |
| if [[ "$(git status --porcelain)" == "" ]]; then
 | |
|     echo "there are no changes";
 | |
|     exit 0;
 | |
| fi
 | |
| git commit -m "Update Trace Viewer
 | |
| Upstream commit: https://github.com/microsoft/playwright/commit/$GITHUB_SHA"
 | |
| git push origin
 | |
| 
 | |
| echo "Pushed changes successfully!"
 |