-
Notifications
You must be signed in to change notification settings - Fork 254
85 lines (76 loc) · 2.67 KB
/
build-and-test-docker.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
name: Docker images
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build-docker-and-test:
name: Build curl-impersonate Docker images and run the tests
runs-on: ubuntu-latest
services:
# A local registry is needed to push the build images to because we use
# the 'docker-container' driver. See
# https://github.com/docker/buildx/issues/301
# and
# See https://github.com/docker/build-push-action/blob/master/docs/advanced/local-registry.md
registry:
image: registry:2
ports:
- 5000:5000
steps:
- name: Check out the repo
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
with:
driver-opts: network=host
# Set up Docker caching. See
# https://github.com/docker/build-push-action/blob/master/docs/advanced/cache.md
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: |
/tmp/.buildx-cache-ff
/tmp/.buildx-cache-ch
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Build the Chrome version of curl-impersonate
uses: docker/build-push-action@v2
with:
push: true
context: chrome/
tags: localhost:5000/curl-impersonate/chrome
cache-from: type=local,src=/tmp/.buildx-cache-ch
cache-to: type=local,dest=/tmp/.buildx-cache-ch-new,mode=max
- name: Build the Firefox version of curl-impersonate
uses: docker/build-push-action@v2
with:
push: true
context: firefox/
tags: localhost:5000/curl-impersonate/ff
cache-from: type=local,src=/tmp/.buildx-cache-ff
cache-to: type=local,dest=/tmp/.buildx-cache-ff-new,mode=max
- name: Build the tests container
uses: docker/build-push-action@v2
with:
load: true
context: tests/
tags: curl-impersonate-tests:latest
build-args: |
FIREFOX_IMAGE=localhost:5000/curl-impersonate/ff
CHROME_IMAGE=localhost:5000/curl-impersonate/chrome
- name: Run the tests
run: docker run --rm curl-impersonate-tests --log-cli-level DEBUG
# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache-ff
mv /tmp/.buildx-cache-ff-new /tmp/.buildx-cache-ff
rm -rf /tmp/.buildx-cache-ch
mv /tmp/.buildx-cache-ch-new /tmp/.buildx-cache-ch