Skip to content

Commit 35bdc3d

Browse files
authored
devops: push Docker image to MCR (microsoft#299)
Closes microsoft#290
1 parent ce9db80 commit 35bdc3d

File tree

4 files changed

+90
-8
lines changed

4 files changed

+90
-8
lines changed

.github/workflows/publish.yml

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ on:
33
release:
44
types: [published]
55
jobs:
6-
deploy:
6+
deploy-pypi:
77
runs-on: ubuntu-latest
88
steps:
99
- uses: actions/checkout@v2
@@ -28,3 +28,40 @@ jobs:
2828
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
2929
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
3030
run: twine upload dist/*
31+
publish-docker:
32+
name: "publish to DockerHub"
33+
runs-on: ubuntu-20.04
34+
if: github.repository == 'microsoft/playwright-python'
35+
steps:
36+
- uses: actions/checkout@v2
37+
- uses: azure/docker-login@v1
38+
with:
39+
login-server: playwright.azurecr.io
40+
username: playwright
41+
password: ${{ secrets.DOCKER_PASSWORD }}
42+
- uses: microsoft/playwright-github-action@v1
43+
- name: Set up Python
44+
uses: actions/setup-python@v2
45+
with:
46+
python-version: 3.8
47+
- name: Install dependencies
48+
run: |
49+
python -m pip install --upgrade pip
50+
pip install -r local-requirements.txt
51+
pip install -e .
52+
- name: Build package
53+
run: python build_package.py
54+
- name: Install
55+
run: python -m playwright install
56+
- name: Build Docker image
57+
run: docker build -t playwright-python:localbuild .
58+
- name: tag & publish
59+
run: |
60+
# GITHUB_REF has a form of `refs/tags/v1.3.0`.
61+
# TAG_NAME would be `v1.3.0`
62+
TAG_NAME=${GITHUB_REF#refs/tags/}
63+
./scripts/tag_image_and_push.sh playwright-python:localbuild playwright.azurecr.io/public/playwright-python:latest
64+
./scripts/tag_image_and_push.sh playwright-python:localbuild playwright.azurecr.io/public/playwright-python:${TAG_NAME}
65+
66+
./scripts/tag_image_and_push.sh playwright-python:localbuild playwright.azurecr.io/public/playwright-python:focal
67+
./scripts/tag_image_and_push.sh playwright:localbuild-focal playwright.azurecr.io/public/playwright-python:${TAG_NAME}-focal
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: "devrelease:docker"
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- release-*
8+
paths:
9+
- .github/workflows/publish_canary_docker.yml
10+
11+
jobs:
12+
publish-canary-docker:
13+
name: "publish to DockerHub"
14+
runs-on: ubuntu-20.04
15+
if: github.repository == 'microsoft/playwright-python'
16+
steps:
17+
- uses: actions/checkout@v2
18+
- uses: azure/docker-login@v1
19+
with:
20+
login-server: playwright.azurecr.io
21+
username: playwright
22+
password: ${{ secrets.DOCKER_PASSWORD }}
23+
- uses: microsoft/playwright-github-action@v1
24+
- name: Set up Python
25+
uses: actions/setup-python@v2
26+
with:
27+
python-version: 3.8
28+
- name: Install dependencies
29+
run: |
30+
python -m pip install --upgrade pip
31+
pip install -r local-requirements.txt
32+
pip install -e .
33+
- name: Build package
34+
run: python build_package.py
35+
- name: Install
36+
run: python -m playwright install
37+
- run: docker build -t playwright-python:localbuild .
38+
- name: tag & publish
39+
run: |
40+
./scripts/tag_image_and_push.sh playwright-python:localbuild playwright.azurecr.io/public/playwright-python:next
41+
./scripts/tag_image_and_push.sh playwright-python:localbuild playwright.azurecr.io/public/playwright-python:next-focal
42+
./scripts/tag_image_and_push.sh playwright-python:localbuild playwright.azurecr.io/public/playwright-python:sha-${{ github.sha }}

.github/workflows/test_docker.yml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ on:
33
push:
44
paths:
55
- '.github/workflows/test_docker.yml'
6-
- 'driver/**'
6+
- 'build_package.py'
77
branches:
88
- master
99
pull_request:
1010
paths:
1111
- '.github/workflows/test_docker.yml'
12-
- 'driver/**'
12+
- 'build_package.py'
1313
branches:
1414
- master
1515
jobs:
@@ -18,10 +18,6 @@ jobs:
1818
runs-on: ubuntu-20.04
1919
steps:
2020
- uses: actions/checkout@v2
21-
- name: Set up Node.js
22-
uses: actions/setup-node@v1
23-
with:
24-
node-version: 12.x
2521
- name: Set up Python
2622
uses: actions/setup-python@v2
2723
with:
@@ -42,4 +38,6 @@ jobs:
4238
CONTAINER_ID="$(docker run --rm -v $(pwd):/root/playwright --name playwright-docker-test -d -t playwright-python:localbuild /bin/bash)"
4339
docker exec --workdir /root/playwright/ "${CONTAINER_ID}" pip install -r local-requirements.txt
4440
docker exec --workdir /root/playwright/ "${CONTAINER_ID}" pip install -e .
45-
docker exec --workdir /root/playwright/ "${CONTAINER_ID}" xvfb-run pytest -vv
41+
docker exec --workdir /root/playwright/ "${CONTAINER_ID}" python build_package.py
42+
docker exec --workdir /root/playwright/ "${CONTAINER_ID}" xvfb-run pytest -vv tests/sync/
43+
docker exec --workdir /root/playwright/ "${CONTAINER_ID}" xvfb-run pytest -vv tests/async/

scripts/tag_image_and_push.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
echo "-- tagging: $2"
4+
docker tag $1 $2
5+
docker push $2

0 commit comments

Comments
 (0)