diff --git a/.github/workflows/count-2.yml b/.github/workflows/count-2.yml new file mode 100644 index 000000000..120046b52 --- /dev/null +++ b/.github/workflows/count-2.yml @@ -0,0 +1,32 @@ +name: Check Line Counts +on: + pull_request_target: + +jobs: + checkbranch: + name: Check PR Branch status + runs-on: ubuntu-latest + outputs: + branchstat: ${{ steps.brstat.outputs.stat}} + steps: + - name: Check code from PR branch + uses: actions/checkout@v4 + with: + repository: ${{ github.event.pull_request.head.repo.full_name }} + ref: ${{ github.event.pull_request.head.sha }} + fetch-depth: 0 + - name: Check whether branch is up-to-date + id: brstat + run: | + git remote add MFC https://github.com/MFlowCode/MFC + git fetch MFC master + echo "${{ github.event.pull_request.head.sha }}" + git rev-list --left-right --count MFC/master...${{ github.event.pull_request.head.sha }} | awk '{print "Behind "$1" - Ahead "$2""}' + count=$(git rev-list --left-right --count MFC/master...${{ github.event.pull_request.head.sha }} | awk '{print $1}') + if [ $count -gt 0 ] + then + echo "Current branch is behind MFC master branch!" + echo "stat=true" >> "$GITHUB_OUTPUT" + else + echo "stat=false" >> "$GITHUB_OUTPUT" + fi