Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/workflows/feature-branch-only-to-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: "Restrict Docs PR merges"

on:
pull_request:
types: [opened, reopened, edited]

jobs:
validate-refs:
name: "Validate Refs"
runs-on: ubuntu-latest
steps:
- name: Validate
run: |
# We allow merging to a branch which is a feature branch for documentation.
if [[ $GITHUB_BASE_REF == aws-docs-* || $GITHUB_BASE_REF == snowflake-docs-* ]]; then
echo "Merging to a feature branch. Allowing."
exit 0
fi

# We allow merging to main so long as it's from a feature branch for documentation.
if [[ $GITHUB_BASE_REF == main && ($GITHUB_HEAD_REF == aws-docs-* || $GITHUB_HEAD_REF == snowflake-docs-*) ]]; then
echo "Merging feature branch to main. Allowing."
exit 0
fi

# All other scenarios aren't valid for merging.
echo "Please ensure all changes are merged to a feature branch. Only feature branches can be merged into main. Rejecting."
exit 1
Loading