-
Notifications
You must be signed in to change notification settings - Fork 51
80 lines (77 loc) · 2.49 KB
/
build-image.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
name: Build and Test
on:
push:
branches:
- '**'
tags-ignore:
- '*'
pull_request:
defaults:
run:
shell: 'bash -Eeuo pipefail -x {0}'
jobs:
generate-matrix:
name: Generate Matrix
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.generate.outputs.matrix }}
steps:
- uses: actions/checkout@master
- id: generate
name: Enumerate Dockerfiles
run: |
matrix="$(dirname */Dockerfile | sort -rn | jq -csR 'rtrimstr("\n") | split("\n") | { directory: . }')"
echo "matrix=$matrix" >> $GITHUB_OUTPUT
build-image:
needs: generate-matrix
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
name: ${{ matrix.directory }}
steps:
- uses: actions/checkout@master
- name: Clone docker-library/official-images (for testing)
run: |
git clone --depth 1 --single-branch https://github.com/docker-library/official-images.git
- name: Build image
run: |
docker version
dir='${{ matrix.directory }}'
img="perl:${dir//,/-}"
docker build -t "$img" "$dir"
- name: Inspect image creation and tag time
run: |
dir='${{ matrix.directory }}'
img="perl:${dir//,/-}"
docker image inspect --format '{{.Created}}' "$img"
docker image inspect --format '{{.Metadata.LastTagTime}}' "$img"
- name: Run tests from docker-library/official-images
run: |
dir='${{ matrix.directory }}'
img="perl:${dir//,/-}"
./official-images/test/run.sh "$img"
- name: Run HTTPS access test
run: |
dir='${{ matrix.directory }}'
img="perl:${dir//,/-}"
docker run "$img" perl -MHTTP::Tiny -E 'if (HTTP::Tiny->new->get("https://github.com")->{status} == 200) { exit 0 } exit 1'
- name: Run cpanm install test
run: |
dir='${{ matrix.directory }}'
img="perl:${dir//,/-}"
docker run "$img" cpanm -v Mojolicious
- name: Run cpm install test
run: |
dir='${{ matrix.directory }}'
img="perl:${dir//,/-}"
docker run "$img" cpm install -v Mojolicious
- name: COPY all to default WORKDIR
run: |
dir='${{ matrix.directory }}'
img="perl:${dir//,/-}"
mkdir -p test/lib
cat <<EOF >Dockerfile
FROM $img
COPY . .
EOF
docker build -f Dockerfile test