Skip to content

Commit c86a443

Browse files
committed
Enable Docker build on PRs for CI validation
The CI workflow now builds the Docker image on pull requests to catch build issues early, but only pushes the image to Docker Hub on main branch updates. This ensures Docker builds are tested for all PRs without publishing images from unmerged code.
1 parent 521bf15 commit c86a443

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

.github/workflows/CI.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,10 @@ jobs:
400400
# taken from https://github.com/docker/build-push-action
401401
needs: [build-and-test, regression-test]
402402
runs-on: ubuntu-latest
403-
if: github.ref == 'refs/heads/main' && github.repository == 'ReactionMechanismGenerator/RMG-Py'
403+
# Run on push to main or on pull requests
404+
if: |
405+
(github.ref == 'refs/heads/main' && github.repository == 'ReactionMechanismGenerator/RMG-Py') ||
406+
(github.event_name == 'pull_request')
404407
steps:
405408
- name: Set up QEMU
406409
uses: docker/setup-qemu-action@v3
@@ -409,15 +412,16 @@ jobs:
409412
uses: docker/setup-buildx-action@v3
410413

411414
- name: Login to Docker Hub
415+
if: github.ref == 'refs/heads/main' && github.repository == 'ReactionMechanismGenerator/RMG-Py'
412416
uses: docker/login-action@v3
413417
with:
414418
username: ${{ secrets.DOCKERHUB_USERNAME }}
415419
password: ${{ secrets.DOCKERHUB_TOKEN }}
416420

417-
- name: Build and Push
421+
- name: Build (and Push if on main)
418422
uses: docker/build-push-action@v6
419423
with:
420-
push: true
424+
push: ${{ github.ref == 'refs/heads/main' && github.repository == 'ReactionMechanismGenerator/RMG-Py' }}
421425
tags: reactionmechanismgenerator/rmg:latest
422426
build-args: |
423427
RMS_Branch=for_rmg

0 commit comments

Comments
 (0)