Skip to main content

Avertissement : « 1 problème a été détecté avec ce workflow : git checkout HEAD^2 n'est plus nécessaire »

Si cet avertissement se produit, mettez à jour votre workflow de façon à suivre les meilleures pratiques actuelles.

À propos de cet avertissement

Warning: 1 issue was detected with this workflow: git checkout HEAD^2 is no longer
necessary. Please remove this step as Code Scanning recommends analyzing the merge
commit for best results.

Si vous utilisez un ancien workflow CodeQL, vous pouvez recevoir cet avertissement lors de l'action « Initialiser CodeQL. »

Confirmation de la cause du problème

Vérifiez la présence des lignes suivantes dans le workflow CodeQL. Ces lignes ont été incluses dans la section steps du travail Analyze dans les versions initiales du workflow CodeQL.

        with:
          # We must fetch at least the immediate parents so that if this is
          # a pull request then we can checkout the head.
          fetch-depth: 2

      # If this run was triggered by a pull request event, then checkout
      # the head of the pull request instead of the merge commit.
      - run: git checkout HEAD^2
        if: ${{ github.event_name == 'pull_request' }}

Résolution du problème

Supprimez les lignes du workflow CodeQL. La section steps révisée du workflow devrait désormais ressembler à ceci :

    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      # Initializes the CodeQL tools for scanning.
      - name: Initialize CodeQL
        uses: github/codeql-action/init@v3

      ...

Pour plus d'informations sur la modification du fichier de workflow CodeQL, consultez « Personnalisation de votre configuration avancée pour l’analyse du code ».