Skip to content

Commit 73b1da6

Browse files
committed
Update Chrome & Chromedriver setup
Chrome needs updating simply because the key seems to have been updated, breaking the Apt setup, so rebuilding alone will handle that. Chromedriver URL and structure has changed, so that needs a larger redo but this seems to work - mostly based on the details from GitHub's script.
1 parent 1bc487d commit 73b1da6

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

chrome.sh

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/bash
22

3-
# Based on https://github.com/nektos/act-environments/blob/940bf53/images/linux/scripts/installers/google-chrome.sh
3+
# Based on https://github.com/nektos/act-environments/blob/cc63076/images/linux/scripts/installers/google-chrome.sh and
4+
# https://github.com/actions/runner-images/blob/845c5ee8/images/ubuntu/scripts/build/install-google-chrome.sh
45

56
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
67
echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" | sudo tee /etc/apt/sources.list.d/google-chrome.list
@@ -15,24 +16,31 @@ if ! command -v google-chrome; then
1516
exit 1
1617
fi
1718

18-
CHROME_VERSION=$(google-chrome --product-version)
19-
CHROME_VERSION=${CHROME_VERSION%.*}
19+
FULL_CHROME_VERSION=$(google-chrome --product-version)
20+
CHROME_VERSION=${FULL_CHROME_VERSION%.*}
21+
22+
echo "Installed Chrome version is $CHROME_VERSION"
2023

2124
# Determine latest release of chromedriver
22-
# Compatibility of Google Chrome and Chromedriver: https://sites.google.com/a/chromium.org/chromedriver/downloads/version-selection
23-
LATEST_CHROMEDRIVER_VERSION=$(curl --fail "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_$CHROME_VERSION")
25+
# Compatibility of Google Chrome and Chromedriver: https://developer.chrome.com/docs/chromedriver/downloads/version-selection
26+
CHROME_PLATFORM="linux64"
27+
CHROME_VERSIONS_URL="https://googlechromelabs.github.io/chrome-for-testing/latest-patch-versions-per-build-with-downloads.json"
28+
CHROME_VERSIONS_JSON=$(curl -fsSL "${CHROME_VERSIONS_URL}")
29+
30+
CHROMEDRIVER_VERSION=$(echo "${CHROME_VERSIONS_JSON}" | jq -r '.builds["'"$CHROME_VERSION"'"].version')
31+
CHROMEDRIVER_URL=$(echo "${CHROME_VERSIONS_JSON}" | jq -r '.builds["'"$CHROME_VERSION"'"].downloads.chromedriver[] | select(.platform=="'"${CHROME_PLATFORM}"'").url')
2432

2533
# Download and unpack latest release of chromedriver
26-
echo "Downloading chromedriver v$LATEST_CHROMEDRIVER_VERSION..."
27-
wget "https://chromedriver.storage.googleapis.com/$LATEST_CHROMEDRIVER_VERSION/chromedriver_linux64.zip"
28-
unzip chromedriver_linux64.zip
29-
rm chromedriver_linux64.zip
34+
echo "Downloading chromedriver v$CHROMEDRIVER_VERSION..."
35+
wget "$CHROMEDRIVER_URL"
36+
unzip chromedriver-linux64.zip
37+
rm chromedriver-linux64.zip
3038

31-
CHROMEDRIVER_DIR="/usr/local/share/chrome_driver"
39+
CHROMEDRIVER_DIR="/usr/local/share/chrome-driver"
3240
CHROMEDRIVER_BIN="$CHROMEDRIVER_DIR/chromedriver"
3341

3442
mkdir -p $CHROMEDRIVER_DIR
35-
mv "chromedriver" $CHROMEDRIVER_BIN
43+
mv "chromedriver-linux64/chromedriver" $CHROMEDRIVER_BIN
3644
chmod +x $CHROMEDRIVER_BIN
3745
ln -s "$CHROMEDRIVER_BIN" /usr/bin/
3846
echo "CHROMEWEBDRIVER=$CHROMEDRIVER_DIR" | tee -a /etc/environment

0 commit comments

Comments
 (0)