From b990fe91c3d863cb9b9cc3e7bc6bf467b91eeb87 Mon Sep 17 00:00:00 2001 From: Vamshi Maskuri <117595548+varshith257@users.noreply.github.com> Date: Thu, 14 Mar 2024 11:42:11 +0530 Subject: [PATCH] Github Actions Added to Block PRs from fork/main branch (#5272) --- .github/actions/block-pr-not-on-main/action.yml | 17 +++++++++++++++++ .github/workflows/ci-lint-checks.yaml | 3 +++ 2 files changed, 20 insertions(+) create mode 100644 .github/actions/block-pr-not-on-main/action.yml 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