Skip to content

Commit b990fe9

Browse files
authored
Github Actions Added to Block PRs from fork/main branch (#5272)
1 parent c78cbdb commit b990fe9

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: 'block-pr-not-on-main'
2+
description: 'Blocks PRs from main branch of forked repository'
3+
runs:
4+
using: "composite"
5+
steps:
6+
- name: Ensure PR is not on main branch
7+
shell: bash
8+
run: |
9+
echo "Repo: ${{ github.repository }}"
10+
echo "Head Repo: ${{ github.event.pull_request.head.repo.full_name }}"
11+
echo "Forked: ${{ github.event.pull_request.head.repo.fork }}"
12+
echo "Branch: ${{ github.event.pull_request.head.ref }}"
13+
14+
if [ "${{ github.event.pull_request.head.repo.fork }}" == "true" ] && [ "${{ github.event.pull_request.head.ref }}" == 'main' ]; then
15+
echo "PRs from the main branch of forked repositories are not allowed."
16+
exit 1
17+
fi

.github/workflows/ci-lint-checks.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,6 @@ jobs:
3535

3636
- name: Lint
3737
run: make lint
38+
39+
- name: Ensure PR is not on main branch
40+
uses: ./.github/actions/block-pr-not-on-main

0 commit comments

Comments
 (0)