Skip to content

ci: fix build-docker-auto re-building Dockerfiles on every PR push#389

Merged
kelly-sovacool merged 1 commit intodevfrom
copilot/fix-unexpected-docker-workflow-trigger
Apr 17, 2026
Merged

ci: fix build-docker-auto re-building Dockerfiles on every PR push#389
kelly-sovacool merged 1 commit intodevfrom
copilot/fix-unexpected-docker-workflow-trigger

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 17, 2026

GitHub's pull_request paths filter matches the full PR diff (base→head), not just the latest commit. Combined with knu/changed-files@v1 using the same full-diff comparison, once any Dockerfile appeared anywhere in a PR, build-docker would re-run for all of them on every subsequent push — even commits that only touched docs or CI files.

Changes

  • Replace knu/changed-files@v1 with git diff HEAD~1 HEAD — scopes Dockerfile detection to the single commit that was just pushed instead of the cumulative PR diff; add fetch-depth: 2 to make the parent commit available
  • Guard build-docker with an if condition — skips the job entirely when the matrix is empty, so the workflow starting (due to the paths filter) no longer causes spurious builds
- id: changed-files
  name: Check changed files
  run: |
    files=$(git diff --name-only HEAD~1 HEAD | grep -E '(^|/)Dockerfile\.' || true)
    ...

build-docker:
  needs: [get-files]
  if: needs.get-files.outputs.json != '[]'

- Replace knu/changed-files@v1 with git diff HEAD~1 HEAD to scope
  file detection to the latest commit only (not full PR diff)
- Add fetch-depth: 2 to get-files checkout for parent commit access
- Guard build-docker job with if condition to skip when matrix is empty

Agent-Logs-Url: https://github.com/CCBR/Dockers2/sessions/40678bbc-3f69-4380-95b3-9af2a243041a

Co-authored-by: kelly-sovacool <17768269+kelly-sovacool@users.noreply.github.com>
@kelly-sovacool
Copy link
Copy Markdown
Member

fixes CCBR/actions#151

@kelly-sovacool kelly-sovacool marked this pull request as ready for review April 17, 2026 18:59
@kelly-sovacool kelly-sovacool merged commit ca75a53 into dev Apr 17, 2026
6 checks passed
@kelly-sovacool kelly-sovacool deleted the copilot/fix-unexpected-docker-workflow-trigger branch April 17, 2026 19:22
kelly-sovacool added a commit to CCBR/actions that referenced this pull request Apr 17, 2026
kelly-sovacool added a commit to CCBR/actions that referenced this pull request Apr 17, 2026
* fix: update build-docker examples from Dockers2

see
CCBR/Dockers2#389

resolves #151

* chore: update CHANGELOG.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants