ci: skip docker-build on PRs that don't change Docker/deps#4
Conversation
Uses dorny/paths-filter to detect changes in docker/, pyproject.toml, uv.lock, requirements.txt or ci.yml. PRs that only touch Python code will skip the ~6-10 min Docker build. To force a build, include '[docker]' in the commit message.
There was a problem hiding this comment.
Pull request overview
This PR updates the CI workflow to skip the Docker image build on PRs unless Docker-related files (or dependency manifests) change, reducing CI runtime for Python-only changes.
Changes:
- Add a
changesjob usingdorny/paths-filterto detect Docker-relevant file modifications. - Gate
docker-buildon thechangesjob output (and an attempted[docker]override).
| if: > | ||
| github.event_name == 'pull_request' || | ||
| needs.changes.outputs.docker == 'true' || | ||
| contains(github.event.head_commit.message, '[docker]') |
There was a problem hiding this comment.
github.event.head_commit.message isn't available for this workflow's triggers (pull_request and workflow_call). With the new condition, Python-only PRs will evaluate contains(github.event.head_commit.message, '[docker]') and the expression can error or never match, so the job gating won't work as intended. Consider switching the override to PR metadata (e.g., github.event.pull_request.title/body) or guarding/null-coalescing the value (e.g., contains(github.event.head_commit.message || '', '[docker]')) and/or computing a force_docker output in the changes job from git log -1.
| contains(github.event.head_commit.message, '[docker]') | |
| contains(github.event.head_commit.message || '', '[docker]') |
| docker-build: | ||
| runs-on: ubuntu-latest | ||
| needs: lint-and-test | ||
| needs: [lint-and-test, changes] | ||
| if: > | ||
| github.event_name == 'pull_request' || | ||
| needs.changes.outputs.docker == 'true' || |
There was a problem hiding this comment.
Because ci.yml is called from deploy.yml via workflow_call on version tags, this new changes/docker-build gating will also be evaluated during CD. If Docker builds are meant to be PR-only (as the PR description suggests), consider guarding these jobs with if: github.event_name == 'pull_request' or adding a workflow input to disable docker builds for CD invocations.
Adds dorny/paths-filter to detect changes and only runs docker-build when:
equirements.txt change
Python-only PRs now skip the ~6-10 min Docker build. CD on tags (deploy.yml + cloudbuild.yaml) is unaffected.