diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index fcdbdf9a83..f115a29815 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -27,8 +27,16 @@ jobs: # against. fetch-depth: 0 - - name: Switch from the detached HEAD of the merge commit to a new branch + - name: Check if the HEAD is detached # Buildx does not work on a detached HEAD + id: is_head_detached + run: | + # return exit code 1 if the head is detached + git symbolic-ref -q HEAD > /dev/null 2>&1 + echo "detached=$?" >> "$GITHUB_OUTPUT" + + - name: Switch from the detached HEAD of the merge commit to a new branch + if: ${{ steps.is_head_detached.outputs.detached }} run: git switch -c new-branch - name: Derive appropriate SHAs for base and head for `nx affected` commands