Skip to content

Commit 3877d64

Browse files
committed
Build the base image on PRs to test before merging
1 parent 1811237 commit 3877d64

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

.github/workflows/build_base_image.yml

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ on:
66
paths:
77
- 'Dockerfile.base'
88
- '.github/workflows/build_base_image.yml'
9+
pull_request:
10+
branches: [main, master, develop]
11+
paths:
12+
- 'Dockerfile.base'
13+
- '.github/workflows/build_base_image.yml'
914
workflow_dispatch:
1015

1116
jobs:
@@ -25,6 +30,7 @@ jobs:
2530
uses: docker/setup-buildx-action@v3
2631

2732
- name: Log in to GitHub Container Registry
33+
if: github.event_name != 'pull_request'
2834
uses: docker/login-action@v3
2935
with:
3036
registry: ghcr.io
@@ -41,7 +47,8 @@ jobs:
4147
run: |
4248
echo "PYVER_SHORT=$(echo ${{ matrix.pyver }} | cut -d'.' -f1,2)" >> $GITHUB_OUTPUT
4349
44-
- name: Build and push base image
50+
- name: Build and push base image (on push)
51+
if: github.event_name != 'pull_request'
4552
uses: docker/build-push-action@v5
4653
with:
4754
context: .
@@ -50,4 +57,16 @@ jobs:
5057
build-args: |
5158
PYTHON_VERSION=${{ matrix.pyver }}
5259
tags: |
53-
ghcr.io/${{ steps.repo.outputs.REPO }}-base:${{ steps.pyver_short.outputs.PYVER_SHORT }}-latest
60+
ghcr.io/${{ steps.repo.outputs.REPO }}-base:${{ steps.pyver_short.outputs.PYVER_SHORT }}-latest
61+
62+
- name: Build base image (on PR)
63+
if: github.event_name == 'pull_request'
64+
uses: docker/build-push-action@v5
65+
with:
66+
context: .
67+
file: Dockerfile.base
68+
push: false
69+
build-args: |
70+
PYTHON_VERSION=${{ matrix.pyver }}
71+
tags: |
72+
ghcr.io/${{ steps.repo.outputs.REPO }}-base:${{ steps.pyver_short.outputs.PYVER_SHORT }}-pr-test

0 commit comments

Comments
 (0)