From a3c3a9c383d85fb271b40178a0a61fe27c339f56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Bj=C3=B6rkert?= Date: Mon, 30 Mar 2026 22:13:22 +0200 Subject: [PATCH 1/2] Add workflow to warn PRs targeting main branch --- .github/workflows/warn_main_pr.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .github/workflows/warn_main_pr.yml diff --git a/.github/workflows/warn_main_pr.yml b/.github/workflows/warn_main_pr.yml new file mode 100644 index 000000000..dee363a19 --- /dev/null +++ b/.github/workflows/warn_main_pr.yml @@ -0,0 +1,27 @@ +name: Warn PR targets main + +on: + pull_request: + types: [opened] + branches: + - main + +jobs: + warn: + if: github.repository_owner == 'loopandlearn' + runs-on: ubuntu-latest + + permissions: + pull-requests: write + + steps: + - name: Comment on PR + uses: actions/github-script@v7 + with: + script: | + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.payload.pull_request.number, + body: '⚠️ This PR targets the `main` branch. We do not accept PRs directly to `main` — please retarget your PR to the `dev` branch instead.' + }); From 8e133269d05131f9bde955a766efa56b976577c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Bj=C3=B6rkert?= Date: Mon, 30 Mar 2026 22:17:46 +0200 Subject: [PATCH 2/2] Use pull_request_target and catch retargeted PRs --- .github/workflows/warn_main_pr.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/warn_main_pr.yml b/.github/workflows/warn_main_pr.yml index dee363a19..c24b78f11 100644 --- a/.github/workflows/warn_main_pr.yml +++ b/.github/workflows/warn_main_pr.yml @@ -1,8 +1,8 @@ name: Warn PR targets main on: - pull_request: - types: [opened] + pull_request_target: + types: [opened, edited] branches: - main