v1.3.0
🚀 [Feature]: Add target branch detection to prevent releases from non-default branch merges (#7)
The action now detects whether a pull request targets the repository's default branch and uses this to determine the correct release type. Releases and site deployments are only triggered when PRs are merged into the default branch, preventing accidental releases from feature branch merges.
Target branch detection
Added detection logic to identify the PR's target branch and compare it against the repository's default branch:
targetBranch- Extracted from the PR's base ref (pullRequest.Base.Ref)defaultBranch- Retrieved from repository info (eventData.Repository.default_branch)isTargetDefaultBranch- Boolean flag indicating whether the PR targets the default branch
ReleaseType logic update
The ReleaseType calculation now factors in the target branch:
| Condition | ReleaseType |
|---|---|
| PR merged to default branch | Release |
| PR merged to non-default branch | None |
| PR closed without merge | Cleanup |
| Open PR with prerelease label | Prerelease |
| Everything else | None |
This ensures that PRs merged into feature branches or other non-default branches do not trigger releases.
Site publishing update
The PublishSite condition now also requires the PR to be merged into the default branch ($isMergedPR -and $isTargetDefaultBranch), ensuring sites are only deployed when merging to the main branch.
Code simplification
Simplified the event data extraction by removing defensive null-checking in favor of relying on Get-GitHubEventData to provide valid data. The action now uses direct property access for cleaner, more readable code.
Logging improvements
The GitHub event inputs logging now includes branch information for debugging:
TargetBranch : main
DefaultBranch : main
IsTargetDefaultBranch : True