diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 273893c..7ed515a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,6 +8,7 @@ permissions: jobs: test: + if: (github.event_name != 'pull_request' && github.event_name != 'pull_request_target') || github.head_ref == 'trunk' name: Test and typecheck runs-on: ubuntu-latest diff --git a/.github/workflows/trunk-guard.yml b/.github/workflows/trunk-guard.yml new file mode 100644 index 0000000..2ddb497 --- /dev/null +++ b/.github/workflows/trunk-guard.yml @@ -0,0 +1,17 @@ +name: Trunk guard + +# Only the `trunk` branch may merge into main. Feature branches merge into +# `trunk` (via the merge train); CI runs only on the trunk -> main PR. +on: + pull_request: + branches: [main] + +jobs: + only-trunk-merges-to-main: + if: github.head_ref != 'trunk' + runs-on: ubuntu-latest + timeout-minutes: 1 + steps: + - run: | + echo "::error::Only the 'trunk' branch may merge into main. Retarget this PR to 'trunk'." + exit 1