From 8e9a511d297ae81ace738ec5cfd1dffb0c9ab648 Mon Sep 17 00:00:00 2001 From: jeremy-then Date: Wed, 30 Oct 2024 11:31:21 -0400 Subject: [PATCH] Testing new codeql config for branch --- .github/workflows/codeql.yml | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index f4329db4..ee2a52d8 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -42,11 +42,42 @@ jobs: path: rskj fetch-depth: 0 + - name: Determine branch to checkout for PR + if: github.event_name == 'pull_request' + working-directory: rskj + env: + PR_BRANCH: ${{ github.head_ref }} + run: | + IS_RSKJ_BRANCH=$(git ls-remote --heads origin "$PR_BRANCH") + if test -n "${IS_RSKJ_BRANCH}"; then + echo "Found matching branch name in RSKj repo" + CHECKOUT_REF="$PR_BRANCH" + else + echo "Using master for RSKj" + CHECKOUT_REF="master" + fi + echo "CHECKOUT_REF=$CHECKOUT_REF" >> $GITHUB_ENV + + - name: Determine branch to checkout for push + if: github.event_name != 'pull_request' + working-directory: rskj + env: + POW_REF: ${{ github.ref_name }} + run: | + IS_RSKJ_REF=$(git ls-remote --heads origin "$POW_REF") + if test -n "${IS_RSKJ_REF}"; then + echo "Found matching ref in RSKj" + CHECKOUT_REF="$POW_REF" + else + echo "Using master for RSKj" + CHECKOUT_REF="master" + fi + echo "CHECKOUT_REF=$CHECKOUT_REF" >> $GITHUB_ENV + - name: Check out appropriate rskj reference - if: ${{ matrix.language == 'java' }} working-directory: rskj env: - CHECKOUT_REF: ${{ github.ref_name }} + CHECKOUT_REF: ${{ env.CHECKOUT_REF }} run: | git switch "$CHECKOUT_REF"