From e964291807b475ecf930ffb4ba86fd3501058f96 Mon Sep 17 00:00:00 2001 From: Dhaval D <343411+ossdhaval@users.noreply.github.com> Date: Fri, 4 Mar 2022 20:49:35 +0530 Subject: [PATCH] fix(ci): fix change identification logic (#966) --- .../workflows/central_code_quality_check.yml | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/.github/workflows/central_code_quality_check.yml b/.github/workflows/central_code_quality_check.yml index 6d5b7d2eae4..b95410124ed 100644 --- a/.github/workflows/central_code_quality_check.yml +++ b/.github/workflows/central_code_quality_check.yml @@ -16,6 +16,7 @@ on: - 'jans-pycloudlib/jans/pycloudlib/version.py' - '**.md' + # TODO: Optimize so that workflow is only triggered for `opened` and `synchronize` actions pull_request: branches: - master @@ -63,18 +64,33 @@ jobs: run: | if [ $GITHUB_BASE_REF ]; then # Pull Request + echo "Triggerring event: pull request" + echo Pull request base ref: $GITHUB_BASE_REF git fetch origin $GITHUB_BASE_REF --depth=1 - echo "CHANGED_DIR=$( git diff --name-only ${{ github.event.before }} ${{ github.event.pull_request.head.sha }} | cut -d/ -f1 | sort -u | sed -z 's/\n/,/g;s/^/[/;s/,$/]/;s/$/\n/')" >> ${GITHUB_ENV} + if [ ${{ github.event.action }} = "opened" ]; then + echo "Triggerring action: opened" + echo "CHANGED_DIR=$( git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | cut -d/ -f1 | sort -u | sed -z 's/\n/,/g;s/^/[/;s/,$/]/;s/$/\n/')" >> ${GITHUB_ENV} + fi + if [ ${{ github.event.action }} = "synchronize" ]; then + echo "Triggerring action: synchronize" + echo "CHANGED_DIR=$( git diff --name-only ${{ github.event.before }} ${{ github.event.pull_request.head.sha }} | cut -d/ -f1 | sort -u | sed -z 's/\n/,/g;s/^/[/;s/,$/]/;s/$/\n/')" >>${GITHUB_ENV} + fi else # Push + echo "Triggerring event: push" git fetch origin ${{ github.event.before }} --depth=1 echo "CHANGED_DIR=$( git diff --name-only ${{ github.event.before }} $GITHUB_SHA | cut -d/ -f1 | sort -u | sed -z 's/\n/,/g;s/^/[/;s/,$/]/;s/$/\n/')" >> ${GITHUB_ENV} fi - name: check env run: | - echo ${{ env.CHANGED_DIR }} - echo ${{ matrix.module }} + echo changed dir list: ${{ env.CHANGED_DIR }} + echo Matrix module: ${{ matrix.module }} + echo GH event action: ${{ github.event.action }} + echo PR base sha: ${{ github.event.pull_request.base.sha }} + echo PR head sha: ${{ github.event.pull_request.head.sha }} + echo event before: ${{ github.event.before }} + echo GH sha: $GITHUB_SHA - name: Set up JDK 11 # JanssenProject/jans-cli is too similar to JanssenProject/jans-client-api as the contains function is returning it belonging to the JVM_PROJECT