Просмотр исходного кода

Add workflow to warn PRs targeting main (#586)

* Add workflow to warn PRs targeting main branch

* Use pull_request_target and catch retargeted PRs
Jonas Björkert 3 месяцев назад
Родитель
Сommit
f0a805a9d0
1 измененных файлов с 27 добавлено и 0 удалено
  1. 27 0
      .github/workflows/warn_main_pr.yml

+ 27 - 0
.github/workflows/warn_main_pr.yml

@@ -0,0 +1,27 @@
+name: Warn PR targets main
+
+on:
+  pull_request_target:
+    types: [opened, edited]
+    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.'
+            });