diff --git a/.github/actions/block-pr-not-on-main/action.yml b/.github/actions/block-pr-not-on-main/action.yml new file mode 100644 index 00000000000..d37fb92990c --- /dev/null +++ b/.github/actions/block-pr-not-on-main/action.yml @@ -0,0 +1,17 @@ +name: 'block-pr-not-on-main' +description: 'Blocks PRs from main branch of forked repository' +runs: + using: "composite" + steps: + - name: Ensure PR is not on main branch + shell: bash + run: | + echo "Repo: ${{ github.repository }}" + echo "Head Repo: ${{ github.event.pull_request.head.repo.full_name }}" + echo "Forked: ${{ github.event.pull_request.head.repo.fork }}" + echo "Branch: ${{ github.event.pull_request.head.ref }}" + + if [ "${{ github.event.pull_request.head.repo.fork }}" == "true" ] && [ "${{ github.event.pull_request.head.ref }}" == 'main' ]; then + echo "PRs from the main branch of forked repositories are not allowed." + exit 1 + fi diff --git a/.github/workflows/ci-lint-checks.yaml b/.github/workflows/ci-lint-checks.yaml index 1525be60037..f025f84dfbd 100644 --- a/.github/workflows/ci-lint-checks.yaml +++ b/.github/workflows/ci-lint-checks.yaml @@ -35,3 +35,6 @@ jobs: - name: Lint run: make lint + + - name: Ensure PR is not on main branch + uses: ./.github/actions/block-pr-not-on-main \ No newline at end of file