Skip to content

Commit 6bbd003

Browse files
authored
ci: gate the dev Docker build on image-affecting paths (#1143)
build-regular is a required status check that ran a full (several-minute) Docker build on every PR, including docs/config-only PRs where the image is byte-for-byte identical (#1134, surfaced merging #1129). Add a paths-filter 'changes' job and gate build-regular's build steps on 'push to main OR image-affecting paths changed'. The job itself always runs, so the required check always reports — avoiding the 'path-filtered required check never reports -> merge deadlock' trap (a workflow-level paths filter would have caused exactly that). Docs/config PRs now report build-regular green in seconds; PRs touching Dockerfile/deps/app/frontend build as before. Release build (build-and-release) is untouched. Closes #1134
1 parent d6c3315 commit 6bbd003

1 file changed

Lines changed: 44 additions & 1 deletion

File tree

.github/workflows/build-dev.yml

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,51 @@ jobs:
7272
echo "This is a PR or manual run - test build only"
7373
fi
7474
75+
# Detect whether this PR touches anything that ends up in the Docker image.
76+
# build-regular is a required status check, so it must always REPORT — the
77+
# expensive build steps below are gated on this output instead of filtering
78+
# the workflow trigger (a path-filtered required check never reports and
79+
# deadlocks merge, even for admins). On push to main the build always runs.
80+
changes:
81+
runs-on: ubuntu-latest
82+
permissions:
83+
pull-requests: read
84+
outputs:
85+
image: ${{ steps.filter.outputs.image }}
86+
steps:
87+
- name: Checkout
88+
uses: actions/checkout@v6
89+
90+
- name: Detect image-affecting changes
91+
uses: dorny/paths-filter@v3
92+
id: filter
93+
with:
94+
filters: |
95+
image:
96+
- 'Dockerfile*'
97+
- 'pyproject.toml'
98+
- 'uv.lock'
99+
- 'open_notebook/**'
100+
- 'api/**'
101+
- 'commands/**'
102+
- 'frontend/**'
103+
- '.github/workflows/build-dev.yml'
104+
105+
# The job always runs (so the required `build-regular` check always reports),
106+
# but every build step is gated on: push to main OR the PR touched an
107+
# image-affecting path (needs.changes.outputs.image). Uses needs.* directly in
108+
# each step `if:` (fully supported) rather than a job-level env indirection.
75109
build-regular:
76-
needs: extract-version
110+
needs: [extract-version, changes]
77111
runs-on: ubuntu-latest
78112
steps:
79113
- name: Checkout
80114
uses: actions/checkout@v6
81115

116+
- name: Skip notice
117+
if: needs.extract-version.outputs.is_push_to_main != 'true' && needs.changes.outputs.image != 'true'
118+
run: echo "No image-affecting paths changed — skipping the Docker build. Reporting success."
119+
82120
- name: Free up disk space
83121
if: needs.extract-version.outputs.is_push_to_main == 'true'
84122
run: |
@@ -90,6 +128,7 @@ jobs:
90128
df -h
91129
92130
- name: Set up Docker Buildx
131+
if: needs.extract-version.outputs.is_push_to_main == 'true' || needs.changes.outputs.image == 'true'
93132
uses: docker/setup-buildx-action@v4
94133

95134
- name: Login to GitHub Container Registry
@@ -108,6 +147,7 @@ jobs:
108147
password: ${{ secrets.DOCKER_PASSWORD }}
109148

110149
- name: Cache Docker layers
150+
if: needs.extract-version.outputs.is_push_to_main == 'true' || needs.changes.outputs.image == 'true'
111151
uses: actions/cache@v5
112152
with:
113153
path: /tmp/.buildx-cache-dev
@@ -117,6 +157,7 @@ jobs:
117157
118158
- name: Prepare Docker tags
119159
id: tags
160+
if: needs.extract-version.outputs.is_push_to_main == 'true' || needs.changes.outputs.image == 'true'
120161
run: |
121162
if [[ "${{ needs.extract-version.outputs.is_push_to_main }}" == "true" ]]; then
122163
# Push to main: build and push v1-dev tags
@@ -135,6 +176,7 @@ jobs:
135176
fi
136177
137178
- name: Build and push regular image
179+
if: needs.extract-version.outputs.is_push_to_main == 'true' || needs.changes.outputs.image == 'true'
138180
uses: docker/build-push-action@v7
139181
with:
140182
context: .
@@ -147,6 +189,7 @@ jobs:
147189
cache-to: type=local,dest=/tmp/.buildx-cache-dev-new,mode=max
148190

149191
- name: Move cache
192+
if: needs.extract-version.outputs.is_push_to_main == 'true' || needs.changes.outputs.image == 'true'
150193
run: |
151194
rm -rf /tmp/.buildx-cache-dev
152195
mv /tmp/.buildx-cache-dev-new /tmp/.buildx-cache-dev

0 commit comments

Comments
 (0)