Skip to content

Commit

Permalink
BI-29: New logic for job updated
Browse files Browse the repository at this point in the history
  • Loading branch information
ayushtiwari110 committed Oct 13, 2023
1 parent 729d401 commit 3f0244b
Showing 1 changed file with 24 additions and 25 deletions.
49 changes: 24 additions & 25 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,31 +64,30 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Check Out Code
uses: actions/checkout@v2

- name: Fetch Main Branch
run: git fetch origin main

- name: Find Common Ancestor
run: |
COMMON=$(git merge-base origin/main HEAD)
echo "::set-output name=common::$COMMON"
- name: Check for Divergence
- name: Check PR Up-to-Date
id: check-pr
run: |
COMMON=${{ steps.find-common.outputs.common }}
BASE=$(git rev-parse $COMMON)
HEAD=$(git rev-parse HEAD)
if [ $BASE != $HEAD ]; then
echo "PR is not up to date with the main branch."
# Get the name of the current pull request branch
PR_BRANCH=$GITHUB_REF
# Set the target branch (the main branch)
BASE_BRANCH=main
# Update the main branch to ensure it's up to date
git fetch origin $BASE_BRANCH:$BASE_BRANCH
# Compare the PR branch with the main branch and list the differing files
DIFF_FILES=$(git diff --name-only $BASE_BRANCH..$PR_BRANCH)
if [[ -z $DIFF_FILES ]]; then
# No differences, the PR is up to date
echo "PR is up-to-date with the main branch."
else
# Differences detected, the PR is not up to date
echo "PR is not up-to-date with the main branch. The following files have changes:"
echo "$DIFF_FILES"
echo "Please update your branch and resolve any conflicts before merging."
exit 1
fi
- name: Status Check
if: failure()
run: echo "Please make sure your PR is up to date with the main branch."

- name: Complete
if: always()
run: echo "PR is up to date with the main branch."
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 3f0244b

Please sign in to comment.