From 91cb0b2b72c1bc78097b25590d0cfbd403b58cfa Mon Sep 17 00:00:00 2001 From: Quetzalli Date: Sun, 28 Jun 2026 22:36:43 +0200 Subject: [PATCH] DOCS: add NEW github actions workflow feature-branch-only-to-main --- .../workflows/feature-branch-only-to-main.yml | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/workflows/feature-branch-only-to-main.yml diff --git a/.github/workflows/feature-branch-only-to-main.yml b/.github/workflows/feature-branch-only-to-main.yml new file mode 100644 index 00000000..8a41d1da --- /dev/null +++ b/.github/workflows/feature-branch-only-to-main.yml @@ -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 \ No newline at end of file