ci: filter main builds to code changes and cancel superseded runs
Apply path filters to the push (merge-to-main) trigger only, so merges that do not change the image (CI/Renovate config, docs) skip the build and release. Pull requests keep running unfiltered so the required check is always reported. Add a concurrency group keyed by ref with cancel-in-progress on main, so a newer merge cancels an older in-flight build and only the most recent release is produced, avoiding tags that would be immediately replaced. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,10 +1,29 @@
|
|||||||
name: Build and publish container
|
name: Build and publish container
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
# On merge to main, only build/release when image-affecting files change;
|
||||||
|
# CI-config, Renovate-config and docs changes do not produce a new image.
|
||||||
push:
|
push:
|
||||||
branches: [main]
|
branches: [main]
|
||||||
|
paths:
|
||||||
|
- 'Dockerfile'
|
||||||
|
- 'default.conf'
|
||||||
|
- 'index.html'
|
||||||
|
- 'styles.css'
|
||||||
|
- 'script.js'
|
||||||
|
- 'messages.js'
|
||||||
|
- '.dockerignore'
|
||||||
|
# Pull requests always run (the build is a required check); no path filter.
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [main]
|
branches: [main]
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
# On main, a newer merge cancels an older in-flight build so only the latest
|
||||||
|
# release is produced, avoiding tags that would be immediately replaced.
|
||||||
|
# Pull request runs are left to finish (cancel only on main).
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
|
cancel-in-progress: ${{ github.ref == 'refs/heads/main' }}
|
||||||
|
|
||||||
defaults:
|
defaults:
|
||||||
run:
|
run:
|
||||||
|
|||||||
Reference in New Issue
Block a user