]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commitdiff
ci: one-shot job to rename SonarCloud main branch from master to main
authorJérôme Benoit <jerome.benoit@sap.com>
Wed, 22 Apr 2026 21:52:47 +0000 (23:52 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Wed, 22 Apr 2026 21:52:47 +0000 (23:52 +0200)
Renames the main branch on all 4 SonarCloud projects via the
project_branches/rename API. Remove this job after first successful run.

.github/workflows/ci.yml

index ea7422f21841e3c2236215cc7a47ff22a7dff93c..8622f6988acc3ee043a2060d0de0970253bc5fde 100644 (file)
@@ -22,6 +22,31 @@ jobs:
             echo "defined=false" >> $GITHUB_OUTPUT;
           fi
 
+  # TODO: remove this job after first successful run
+  fix-sonarcloud-main-branch:
+    needs: [check-secrets]
+    if: ${{ needs.check-secrets.outputs.sonar-token-exists == 'true' && github.event_name == 'push' }}
+    runs-on: ubuntu-latest
+    steps:
+      - name: Rename SonarCloud main branch from master to main
+        env:
+          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
+        run: |
+          for project in \
+            e-mobility-charging-stations-simulator \
+            e-mobility-charging-stations-simulator-ui-common \
+            e-mobility-charging-stations-simulator-cli \
+            e-mobility-charging-stations-simulator-webui
+          do
+            http_code=$(curl --silent --output /dev/null --write-out '%{http_code}' \
+              --request POST \
+              'https://sonarcloud.io/api/project_branches/rename' \
+              -H "Authorization: Bearer ${SONAR_TOKEN}" \
+              -H 'Content-Type: application/x-www-form-urlencoded' \
+              -d "project=${project}&name=main")
+            echo "${project}: HTTP ${http_code}"
+          done
+
   build-ocpp-server:
     strategy:
       matrix: