Explorar el Código

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 hace 3 meses
padre
commit
f0a805a9d0
Se han modificado 1 ficheros con 27 adiciones y 0 borrados
  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.'
+            });