Skip to content

ci: do not run cd when a branch is created - #1881

Merged
radu-mocanu merged 1 commit into
mainfrom
ci/skip-cd-on-branch-creation
Sep 3, 2026
Merged

ci: do not run cd when a branch is created#1881
radu-mocanu merged 1 commit into
mainfrom
ci/skip-cd-on-branch-creation

Conversation

@radu-mocanu

Copy link
Copy Markdown
Collaborator

CD triggers on pushes to main and release/** filtered to packages/*/pyproject.toml. Creating a release/* branch at a commit that touched one of those files is a push that can match the filter, so the branch creation itself starts a CD run.

This repo already resolves safely, because detect_publishable_packages.py asks PyPI whether each local version exists and the publish steps use skip-existing: true. The remaining gap is the same as in the sibling repos: if a version bump on main was never actually published, branch creation would publish it from a branch nobody treated as a release. The pypi environment has no protection rules or deployment branch policy, so there is no second gate.

Skip detection on branch creation rather than skipping the whole job. Several downstream jobs use always(), so a skipped detect-publishable-packages would leave them evaluating fromJson('') and erroring. Falling back to '[]' and '0' in the job outputs keeps the expressions valid and makes every downstream contains(...) false, so the tiers skip cleanly. The fallback also covers the case where the script exits without writing its outputs.

Manual workflow_dispatch runs are unaffected, since the property is absent there and evaluates as falsy. Merging a hotfix PR into a release branch is a normal push with commits, so created is false and the publish still runs as intended.

Copilot AI lite review requested due to automatic review settings September 3, 2026 07:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The workflow change is minimal, aligns with the described failure mode, and safely preserves downstream condition evaluation by providing valid default outputs.

Pull request overview

Prevents the CD workflow from publishing packages when a release/** branch is created (which GitHub reports as a push event), by skipping publishable-package detection on branch creation while keeping downstream job conditions safe.

Changes:

  • Added a step-level guard (if: ${{ !github.event.created }}) so detection does not run on branch creation pushes.
  • Added safe default job outputs ('[]' / '0') so downstream fromJson(...) and contains(...) expressions remain valid even when detection is skipped or produces no outputs.
File summaries
File Description
.github/workflows/cd.yml Skips detection on branch creation and provides fallback outputs to avoid downstream expression failures and unintended publishes.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@sonarqubecloud

sonarqubecloud Bot commented Sep 3, 2026

Copy link
Copy Markdown

@radu-mocanu
radu-mocanu merged commit 5695b19 into main Sep 3, 2026
53 checks passed
@radu-mocanu
radu-mocanu deleted the ci/skip-cd-on-branch-creation branch September 3, 2026 11:29
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.

3 participants