From 37542e64855ce21bd580f973ae5ce1ed86812a7a Mon Sep 17 00:00:00 2001 From: Richard Si <63936253+ichard26@users.noreply.github.com> Date: Sat, 31 Dec 2022 01:52:35 -0500 Subject: [PATCH] Fail lint CI if the PR doesn't target main (#3477) Let's skip the check if we're running on a fork just in case someone opens a PR against a branch on said fork as part of a PR review upstream. --- .github/workflows/lint.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 90c4801..064d474 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -16,6 +16,13 @@ jobs: steps: - uses: actions/checkout@v3 + - name: Assert PR target is main + if: github.event_name == 'pull_request' && github.repository == 'psf/black' + run: | + if [ "$GITHUB_BASE_REF" != "main" ]; then + echo "::error::PR targeting '$GITHUB_BASE_REF', please refile targeting 'main'." && exit 1 + fi + - name: Set up latest Python uses: actions/setup-python@v4 with: -- 2.39.5