feat: Add PR promotion path enforcement workflow #497
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Purpose
This PR introduces a GitHub Actions workflow to enforce a specific promotion path for pull requests. This ensures that code changes are promoted through predefined branches in a controlled manner, preventing accidental or incorrect deployments.
Approach
A new workflow file,
.github/workflows/flow-guard.yml, has been added. This workflow is triggered on pull request events (opened, synchronized, reopened). It checks the base and head branches of the pull request to validate that the promotion path adheres to the following rules:stagingmust originate fromdev.mastermust originate fromstaging.If the promotion path is invalid, the workflow will fail, informing the user of the error.
Key Modifications
.github/workflows/flow-guard.ymlto define the GitHub Actions workflow.stagingandmasterbranches.Important Technical Details
github.event.pull_request.base.refandgithub.event.pull_request.head.refto access the target and source branches, respectively.Types of changes