Skip to content

Commit

Permalink
Github Actions Added to Block PRs from fork/main branch (#5272)
Browse files Browse the repository at this point in the history
  • Loading branch information
varshith257 committed Mar 14, 2024
1 parent c78cbdb commit b990fe9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .github/actions/block-pr-not-on-main/action.yml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions .github/workflows/ci-lint-checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit b990fe9

Please sign in to comment.