Skip to content

Commit a192e95

Browse files
authored
Merge pull request #200 from umihico/feat/restart-updating-chrome
Restart updating chrome with GoogleChromeLabs API
2 parents 679e408 + ee302b6 commit a192e95

File tree

4 files changed

+20
-53
lines changed

4 files changed

+20
-53
lines changed

.github/workflows/auto-update.yml

Lines changed: 15 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -25,52 +25,26 @@ jobs:
2525
SHA256_DIGEST=$(docker inspect public.ecr.aws/lambda/python:latest | jq -r '.[0].RepoDigests[0] | split(":") | .[1]' )
2626
echo "SHA256_DIGEST=${SHA256_DIGEST}" >> $GITHUB_OUTPUT
2727
- name: Note Chromium versions
28-
id: chromium-versions
28+
id: chrome-versions
2929
run: |
30-
echo "CHANNEL=stable" >> $GITHUB_OUTPUT
31-
echo "MAJOR_VERSION=114" >> $GITHUB_OUTPUT
32-
echo "POSITION=1135561" >> $GITHUB_OUTPUT
33-
exit 0
34-
# This way of getting Chromium version is not working anymore. https://chromedriver.chromium.org/downloads
35-
WHOLE_JSON=$(curl https://omahaproxy.appspot.com/all.json)
36-
JSON=$(echo $WHOLE_JSON | jq -r '.[] | select(.os=="linux") | .versions[] | select(.channel=="stable")')
37-
CHANNEL="stable"
38-
POSITION=$(echo $JSON | jq -r '.branch_base_position')
39-
if (( POSITION < 900000 )); then
40-
JSON=$(echo $WHOLE_JSON | jq -r '.[] | select(.os=="linux") | .versions[] | select(.channel=="beta")')
41-
CHANNEL="beta"
42-
POSITION=$(echo $JSON | jq -r '.branch_base_position')
43-
echo "CHANNEL=${CHANNEL}" >> $GITHUB_OUTPUT
44-
fi
45-
46-
MAJOR_VERSION=$(echo $JSON | jq -r '.version | split(".") | .[0]')
30+
WHOLE_JSON=$(curl https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions-with-downloads.json)
31+
CHANNEL="Stable"
32+
REVISION=$(echo $WHOLE_JSON | jq -r '.channels.Stable.revision')
33+
echo "REVISION=${REVISION}" >> $GITHUB_OUTPUT
34+
CHROME_VERSION=$(echo $WHOLE_JSON | jq -r '.channels.Stable.version')
35+
echo "CHROME_VERSION=${CHROME_VERSION}" >> $GITHUB_OUTPUT
36+
MAJOR_VERSION=$(echo $WHOLE_JSON | jq -r '.channels.Stable.version | split(".") | .[0]')
4737
echo "MAJOR_VERSION=${MAJOR_VERSION}" >> $GITHUB_OUTPUT
48-
49-
for _ in {1..100}; do
50-
DOWNLOAD_URL="https://www.googleapis.com/download/storage/v1/b/chromium-browser-snapshots/o/Linux_x64%2F${POSITION}%2Fchrome-linux.zip?alt=media"
51-
curl -I $DOWNLOAD_URL | head -1 | grep -q 404 || break
52-
POSITION=$(($POSITION-1))
53-
sleep 1
54-
done
55-
56-
echo "POSITION=${POSITION}" >> $GITHUB_OUTPUT
57-
- name: Note chromedriver version
58-
id: chromedriver-version
59-
run: |
60-
MAJOR_VERSION=${{ steps.chromium-versions.outputs.MAJOR_VERSION }}
61-
DRIVER_VERSION=$(curl "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_${MAJOR_VERSION}")
62-
echo "DRIVER_VERSION=${DRIVER_VERSION}" >> $GITHUB_OUTPUT
6338
- name: Update Selenium
6439
id: selenium-version
6540
run: |
6641
echo "SELENIUM_VERSION=$(curl -s https://pypi.org/pypi/selenium/json | jq -r .info.version)" >> $GITHUB_OUTPUT
6742
- name: Update Dockerfile
6843
run: |
6944
SHA256_DIGEST=${{ steps.docker-image-digest.outputs.SHA256_DIGEST }}
70-
POSITION=${{ steps.chromium-versions.outputs.POSITION }}
71-
DRIVER_VERSION=${{ steps.chromedriver-version.outputs.DRIVER_VERSION }}
45+
CHROME_VERSION=${{ steps.chrome-versions.outputs.CHROME_VERSION }}
7246
SELENIUM_VERSION=${{ steps.selenium-version.outputs.SELENIUM_VERSION }}
73-
sed -r "s/public.ecr.aws\/lambda\/python[:@a-z0-9]+/public.ecr.aws\/lambda\/python\@sha256\:${SHA256_DIGEST}/g; s/chromedriver.storage.googleapis.com\/[0-9.]+/chromedriver.storage.googleapis.com\/${DRIVER_VERSION}/g; s/Linux_x64%2F[0-9]+%2Fchrome-linux.zip/Linux_x64%2F${POSITION}%2Fchrome-linux.zip/g; s/selenium==[0-9\.]*/selenium==${SELENIUM_VERSION}/g" -i Dockerfile
47+
sed -r "s/public.ecr.aws\/lambda\/python[:@a-z0-9]+/public.ecr.aws\/lambda\/python\@sha256\:${SHA256_DIGEST}/g; s/chrome-for-testing\/[0-9.]+/chrome-for-testing\/${CHROME_VERSION}/g; s/selenium==[0-9\.]*/selenium==${SELENIUM_VERSION}/g" -i Dockerfile
7448
- name: Deploy
7549
run: sls deploy
7650
env:
@@ -104,11 +78,10 @@ jobs:
10478
run: cat /tmp/scraping-result.txt | grep -q "This domain is for use in illustrative examples in documents"
10579
- name: Update README
10680
run: |
107-
CHROME_VERSION=${{ steps.chrome-version.outputs.CHROME_VERSION }}
108-
DRIVER_VERSION=${{ steps.chromedriver-version.outputs.DRIVER_VERSION }}
81+
CHROME_VERSION=${{ steps.chrome-versions.outputs.CHROME_VERSION }}
10982
SELENIUM_VERSION=${{ steps.selenium-version.outputs.SELENIUM_VERSION }}
11083
PYTHON_VERSION=${{ steps.python-version.outputs.PYTHON_VERSION }}
111-
sed -r "s/- chromium [0-9.]+/- chromium ${CHROME_VERSION}/g; s/- chromedriver [0-9.]+/- chromedriver ${DRIVER_VERSION}/g; s/- selenium [0-9.]+/- selenium ${SELENIUM_VERSION}/g; s/- Python [0-9.]+/- Python ${PYTHON_VERSION}/g" -i README.md
84+
sed -r "s/- chromium [0-9.]+/- chromium ${CHROME_VERSION}/g; s/- chromedriver [0-9.]+/- chromedriver ${CHROME_VERSION}/g; s/- selenium [0-9.]+/- selenium ${SELENIUM_VERSION}/g; s/- Python [0-9.]+/- Python ${PYTHON_VERSION}/g" -i README.md
11285
- name: Detect changes
11386
id: detect-changes
11487
run: |
@@ -129,11 +102,10 @@ jobs:
129102
git checkout -b $BRANCH
130103
git add Dockerfile README.md
131104
echo "SHA256_DIGEST=${{ steps.docker-image-digest.outputs.SHA256_DIGEST }}" > /tmp/body-text.txt
132-
echo "POSITION=${{ steps.chromium-versions.outputs.POSITION }}" >> /tmp/body-text.txt
133-
echo "DRIVER_VERSION=${{ steps.chromedriver-version.outputs.DRIVER_VERSION }}" >> /tmp/body-text.txt
105+
echo "REVISION=${{ steps.chrome-versions.outputs.REVISION }}" >> /tmp/body-text.txt
134106
echo "PYTHON_VERSION=${{ steps.python-version.outputs.PYTHON_VERSION }}" >> /tmp/body-text.txt
135107
echo "SELENIUM_VERSION=${{ steps.selenium-version.outputs.SELENIUM_VERSION }}" >> /tmp/body-text.txt
136-
echo -e "CHROME_VERSION=${{ steps.chrome-version.outputs.CHROME_VERSION }}\n\n" >> /tmp/body-text.txt
108+
echo -e "CHROME_VERSION=${{ steps.chrome-versions.outputs.CHROME_VERSION }}\n\n" >> /tmp/body-text.txt
137109
git diff --staged >> /tmp/body-text.txt
138110
git commit -m "${TITLE}"
139111
git push --set-upstream origin $BRANCH
@@ -151,7 +123,7 @@ jobs:
151123
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
152124
PYTHON_VERSION=${{ steps.python-version.outputs.PYTHON_VERSION }}
153125
SELENIUM_VERSION=${{ steps.selenium-version.outputs.SELENIUM_VERSION }}
154-
CHROME_VERSION=${{ steps.chrome-version.outputs.CHROME_VERSION }}
126+
CHROME_VERSION=${{ steps.chrome-versions.outputs.CHROME_VERSION }}
155127
MAJOR_PYTHON_VERSION=$(echo $PYTHON_VERSION | cut -d "." -f 1)
156128
MINOR_PYTHON_VERSION=$(echo $PYTHON_VERSION | cut -d "." -f 2)
157129
docker image tag serverless-docker-selenium-lambda-prod:img umihico/aws-lambda-selenium-python:latest

Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
FROM public.ecr.aws/lambda/python@sha256:0b8d0fa373384edace5d97e7f96e835fe43f065045a0bcb09e0dbc20fc33d351 as build
22
RUN yum install -y unzip && \
3-
curl -Lo "/tmp/chromedriver.zip" "https://chromedriver.storage.googleapis.com/114.0.5735.90/chromedriver_linux64.zip" && \
4-
curl -Lo "/tmp/chrome-linux.zip" "https://www.googleapis.com/download/storage/v1/b/chromium-browser-snapshots/o/Linux_x64%2F1135561%2Fchrome-linux.zip?alt=media" && \
5-
unzip /tmp/chromedriver.zip -d /opt/ && \
6-
unzip /tmp/chrome-linux.zip -d /opt/
3+
curl -Lo "/tmp/chromedriver-linux64.zip" "https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/117.0.5938.92/linux64/chromedriver-linux64.zip" && \
4+
curl -Lo "/tmp/chrome-linux64.zip" "https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/117.0.5938.92/linux64/chrome-linux64.zip" && \
5+
unzip /tmp/chromedriver-linux64.zip -d /opt/ && \
6+
unzip /tmp/chrome-linux64.zip -d /opt/
77

88
FROM public.ecr.aws/lambda/python@sha256:0b8d0fa373384edace5d97e7f96e835fe43f065045a0bcb09e0dbc20fc33d351
99
RUN yum install atk cups-libs gtk3 libXcomposite alsa-lib \

README.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@
33
![badge](https://github.com/umihico/docker-selenium-lambda/actions/workflows/demo-test.yml/badge.svg)
44
![badge](https://github.com/umihico/docker-selenium-lambda/actions/workflows/auto-update.yml/badge.svg)
55

6-
> :warning: **Caution!**
7-
>
8-
> Updating Chromium and Chromedriver versions to v115 or later is postponed in this repository. I'll try to fix later.
9-
> See https://chromedriver.chromium.org/downloads
10-
116
This is minimum demo of headless chrome and selenium on container image on AWS Lambda
127

138
This image goes with these versions. [These are automatically updated and tested everyday.](https://github.com/umihico/docker-selenium-lambda/actions)

main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def handler(event=None, context=None):
88
service = webdriver.ChromeService("/opt/chromedriver")
99

1010
options.binary_location = '/opt/chrome/chrome'
11-
options.add_argument('--headless')
11+
options.add_argument("--headless=new")
1212
options.add_argument('--no-sandbox')
1313
options.add_argument("--disable-gpu")
1414
options.add_argument("--window-size=1280x1696")

0 commit comments

Comments
 (0)