Skip to content

Commit 26376f5

Browse files
committed
workflows: build image only on build context changes
Also switch to using docker-buildx, and remove unneeded step.
1 parent 3db6a43 commit 26376f5

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

.github/workflows/build-image.yml

+19-18
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
name: Build and Test
22

33
on:
4-
push:
5-
branches:
6-
- '**'
7-
tags-ignore:
8-
- '*'
94
pull_request:
5+
paths:
6+
- '**/Dockerfile'
7+
- '!.devcontainer/Dockerfile'
8+
- '**/DevelPatchPerl.patch'
109

1110
defaults:
1211
run:
@@ -18,46 +17,56 @@ jobs:
1817
runs-on: ubuntu-latest
1918
outputs:
2019
matrix: ${{ steps.generate.outputs.matrix }}
20+
2121
steps:
22-
- uses: actions/checkout@master
22+
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
23+
2324
- id: generate
2425
name: Enumerate Dockerfiles
2526
run: |
2627
matrix="$(dirname */Dockerfile | sort -rn | jq -csR 'rtrimstr("\n") | split("\n") | { directory: . }')"
2728
echo "matrix=$matrix" >> $GITHUB_OUTPUT
29+
2830
build-image:
2931
needs: generate-matrix
3032
runs-on: ubuntu-latest
3133
strategy:
3234
matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
3335
name: ${{ matrix.directory }}
36+
3437
steps:
35-
- uses: actions/checkout@master
38+
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
39+
3640
- name: Clone docker-library/official-images (for testing)
3741
run: |
3842
git clone --depth 1 --single-branch https://github.com/docker-library/official-images.git
43+
3944
- name: Build image
4045
run: |
4146
docker version
4247
dir='${{ matrix.directory }}'
4348
img="perl:${dir//,/-}"
44-
docker build -t "$img" "$dir"
49+
docker buildx build --progress=plain -t "$img" "$dir"
50+
4551
- name: Inspect image creation and tag time
4652
run: |
4753
dir='${{ matrix.directory }}'
4854
img="perl:${dir//,/-}"
4955
docker image inspect --format '{{.Created}}' "$img"
5056
docker image inspect --format '{{.Metadata.LastTagTime}}' "$img"
57+
5158
- name: Run tests from docker-library/official-images
5259
run: |
5360
dir='${{ matrix.directory }}'
5461
img="perl:${dir//,/-}"
5562
./official-images/test/run.sh "$img"
63+
5664
- name: Run HTTPS access test
5765
run: |
5866
dir='${{ matrix.directory }}'
5967
img="perl:${dir//,/-}"
6068
docker run "$img" perl -MHTTP::Tiny -E 'if (HTTP::Tiny->new->get("https://github.com")->{status} == 200) { exit 0 } exit 1'
69+
6170
- name: Run cpanm install test
6271
run: |
6372
dir='${{ matrix.directory }}'
@@ -67,13 +76,15 @@ jobs:
6776
docker run "$img" cpanm -v Net::[email protected]_02
6877
fi
6978
docker run "$img" cpanm -v Mojolicious
79+
7080
- name: Run cpanm no-lwp by default test
7181
run: |
7282
dir='${{ matrix.directory }}'
7383
img="perl:${dir//,/-}"
7484
if [[ "$dir" != *"slim"* ]]; then
7585
docker run "$img" bash -c "cpanm -v -n LWP && cpanm -v -n local::lib"
7686
fi
87+
7788
- name: Run cpm install test
7889
run: |
7990
dir='${{ matrix.directory }}'
@@ -83,13 +94,3 @@ jobs:
8394
docker run "$img" cpm install -v Net::[email protected]_02
8495
fi
8596
docker run "$img" cpm install -v Mojolicious
86-
- name: COPY all to default WORKDIR
87-
run: |
88-
dir='${{ matrix.directory }}'
89-
img="perl:${dir//,/-}"
90-
mkdir -p test/lib
91-
cat <<EOF >Dockerfile
92-
FROM $img
93-
COPY . .
94-
EOF
95-
docker build -f Dockerfile test

0 commit comments

Comments
 (0)