Skip to content

The main branch is no more than 5 commits ahead #493

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
22 changes: 21 additions & 1 deletion .github/workflows/build-and-run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,30 @@ on:
branches: [main]

jobs:
commits_behind_the_main:
if: ${{ github.event_name == 'pull_request' }}
runs-on: ubuntu-20.02
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: "Add commits number ahead of the main to env"
run: echo COMMITS_AHEAD_MAIN=$(git rev-list --left-only --count ${GITHUB_REF_NAME}...origin/main) >> $GITHUB_ENV

- name: "Output information"
run: echo "The ${GITHUB_REF_NAME} is ahead of the [origin/main] by ${{ env.COMMITS_AHEAD_MAIN }} commits"

- name: "Fails if the current branch is ahead of the [origin/main] by more than 5 commits"
if: ${{ env.COMMITS_AHEAD_MAIN > 5 }}
run: exit 1

build_and_run_tests:
needs: commits_behind_the_main
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: actions/setup-java@v2
with:
java-version: '8'
Expand Down