Skip to content
This repository has been archived by the owner on Oct 14, 2022. It is now read-only.

ci: add base branch check for PRs #1

Merged
merged 2 commits into from
Jun 10, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .github/workflows/branches.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Branches

on: [pull_request]

jobs:
check-base-branch:
name: Check Base
runs-on: ubuntu-latest
steps:
- name: Branch is related to CI and is based on main
if: ${{ startsWith(github.head_ref, 'ci/') && github.base_ref == 'main' }}
env:
BASE_BRANCH: ${{ github.base_ref }}
run: |
echo "Current base branch: $BASE_BRANCH"
echo "Branch rule exception: Continuous Integration branches allowed to be merged into main"
- name: Branch is related to CI and is not based on main
if: ${{ startsWith(github.head_ref, 'ci/') && github.base_ref != 'main' }}
env:
BASE_BRANCH: ${{ github.base_ref }}
run: |
echo "Current base branch: $BASE_BRANCH"
echo "Branch rule exception: Continuous Integration branches must only be merged into main"
echo 1
- name: Branch is not based on develop
if: ${{ github.base_ref != 'develop' && !startsWith(github.head_ref, 'ci/') }}
env:
BASE_BRANCH: ${{ github.base_ref }}
run: |
echo "Current base branch: $BASE_BRANCH"
echo "PRs should only ever be merged into develop"
exit 1
- name: Branch verified as based on develop branch
if: ${{ github.base_ref == 'develop' && !startsWith(github.head_ref, 'ci/') }}
env:
BASE_BRANCH: ${{ github.base_ref }}
run: |
echo "Branch is correctly branched off of valid base branch to merge PRs into: $BASE_BRANCH"