Skip to content

Commit f0863fc

Browse files
committed
CI: support run docker build/test on PR
Enable both docker-cbdb-build-containers and docker-cbdb-test-containers workflows to run on pull_request when files under their respective Docker paths change. Main changes: * Add pull_request triggers with path filters: - build: devops/deploy/docker/build/** - test: devops/deploy/docker/test/** Guard Docker hub login and multi-arch push steps so they run only push to refs/heads/main.
1 parent 2edd83a commit f0863fc

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

.github/workflows/docker-cbdb-build-containers.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ on:
6161
- 'devops/deploy/docker/build/rocky8/**'
6262
- 'devops/deploy/docker/build/rocky9/**'
6363
- 'devops/deploy/docker/build/ubuntu22.04/**'
64+
pull_request:
65+
paths:
66+
- 'devops/deploy/docker/build/**'
6467
workflow_dispatch: # Manual trigger
6568

6669
# Prevent multiple workflow runs from interfering with each other
@@ -116,7 +119,7 @@ jobs:
116119
# Login to DockerHub for pushing images
117120
# Requires DOCKERHUB_USER and DOCKERHUB_TOKEN secrets to be set
118121
- name: Login to Docker Hub
119-
if: ${{ steps.platform-filter.outputs[matrix.platform] == 'true' }}
122+
if: ${{ steps.platform-filter.outputs[matrix.platform] == 'true' && github.event_name == 'push' && github.ref == 'refs/heads/main' }}
120123
uses: docker/login-action@v3
121124
with:
122125
username: ${{ secrets.DOCKERHUB_USER }}
@@ -165,7 +168,7 @@ jobs:
165168
# Build and push multi-architecture images
166169
# This creates a manifest list that supports both architectures
167170
- name: Build and Push Multi-arch Docker images
168-
if: ${{ steps.platform-filter.outputs[matrix.platform] == 'true' }}
171+
if: ${{ steps.platform-filter.outputs[matrix.platform] == 'true' && github.event_name == 'push' && github.ref == 'refs/heads/main' }}
169172
uses: docker/build-push-action@v6
170173
with:
171174
context: ./devops/deploy/docker/build/${{ matrix.platform }}

.github/workflows/docker-cbdb-test-containers.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ on:
5050
- 'devops/deploy/docker/test/rocky8/**'
5151
- 'devops/deploy/docker/test/rocky9/**'
5252
- 'devops/deploy/docker/test/ubuntu22.04/**'
53+
pull_request:
54+
paths:
55+
- 'devops/deploy/docker/test/**'
5356
workflow_dispatch: # Manual trigger
5457

5558
# Prevent multiple workflow runs from interfering with each other
@@ -104,7 +107,7 @@ jobs:
104107

105108
# Login to DockerHub for pushing images
106109
- name: Login to Docker Hub
107-
if: ${{ steps.platform-filter.outputs[matrix.platform] == 'true' }}
110+
if: ${{ steps.platform-filter.outputs[matrix.platform] == 'true' && github.event_name == 'push' && github.ref == 'refs/heads/main' }}
108111
uses: docker/login-action@v3
109112
with:
110113
username: ${{ secrets.DOCKERHUB_USER }}
@@ -135,7 +138,7 @@ jobs:
135138
# Build and push multi-architecture images
136139
# Creates a manifest list that supports both architectures
137140
- name: Build and Push Multi-arch Docker images
138-
if: ${{ steps.platform-filter.outputs[matrix.platform] == 'true' }}
141+
if: ${{ steps.platform-filter.outputs[matrix.platform] == 'true' && github.event_name == 'push' && github.ref == 'refs/heads/main' }}
139142
uses: docker/build-push-action@v6
140143
with:
141144
context: ./devops/deploy/docker/test/${{ matrix.platform }}

0 commit comments

Comments
 (0)