Skip to main content

Aviso: "1 issue was detected with this workflow: git checkout HEAD^2 is no longer necessary"

Se você receber esse aviso, deve atualizar seu fluxo de trabalho para seguir as melhores práticas atuais.

Se você estiver usando um fluxo de trabalho antigo de CodeQL, você poderá receber o aviso a seguir na saída "Inicializar CodeQL" da ação:

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.

Corrija isto removendo as seguintes linhas do fluxo de trabalho CodeQL. Essas linhas foram incluídas na seção steps do trabalho Analyze nas versões iniciais do fluxo de trabalho do 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' }}

A seção revisada steps do fluxo de trabalho terá esta aparência:

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

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

      ...

Para obter mais informações sobre como editar o arquivo de fluxo de trabalho do CodeQL, confira "Como personalizar sua configuração avançada para a verificação de código".