From 0dbfe359f67aa3eac470776fa3e894931ddf93ee Mon Sep 17 00:00:00 2001 From: Carlo Cabrera <30379873+carlocab@users.noreply.github.com> Date: Wed, 30 Oct 2024 23:13:08 +0800 Subject: [PATCH] publish-commit-bottles: publish bottles only for formulae changes We occasionally see this workflow mistakenly attempting to publish bottles for PRs that do not modify any formulae. See, for example, Homebrew/homebrew-core#196103. --- .github/workflows/publish-commit-bottles.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/publish-commit-bottles.yml b/.github/workflows/publish-commit-bottles.yml index 032aa9cef0545..21daf6426fbb3 100644 --- a/.github/workflows/publish-commit-bottles.yml +++ b/.github/workflows/publish-commit-bottles.yml @@ -147,6 +147,20 @@ jobs: fi done < <(jq --raw-output '.labels[].name' <<< "$pr_data") + if [[ "$bottles" = "true" ]] + then + if jq --exit-status 'any(.[].filename; startswith("Formula/")) | not' + then + echo '::notice ::PR does not modify formulae; no bottles to publish.' + bottles=false + fi < <( + gh api \ + --header 'Accept: application/vnd.github+json' \ + --header 'X-GitHub-Api-Version: 2022-11-28' \ + "repos/$GH_REPO/pulls/$PR/files" + ) + fi + requires_merge=true if [[ "$merged" = "true" || "$automerge_enabled" = "true" ]] then