From fb705c234f9201c69ff39f4f74f4ae5035f18cda Mon Sep 17 00:00:00 2001 From: Emma Thorpe Date: Fri, 12 Jun 2026 12:34:13 +0100 Subject: [PATCH] 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, so a newer run supersedes an older in-flight run: a fresh merge to main cancels the previous 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) --- .gitea/workflows/build-and-publish.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/.gitea/workflows/build-and-publish.yml b/.gitea/workflows/build-and-publish.yml index 1b7542c..2b51e6e 100644 --- a/.gitea/workflows/build-and-publish.yml +++ b/.gitea/workflows/build-and-publish.yml @@ -1,10 +1,30 @@ name: Build and publish container 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: 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: branches: [main] + workflow_dispatch: + +# A newer run cancels an older in-flight run in the same group (keyed by ref), +# so a fresh merge to main supersedes the previous build and only the latest +# release is produced, avoiding tags that would be immediately replaced. Each +# pull request likewise supersedes only its own earlier runs. +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true defaults: run: