Skip to content

Git safe directory only set in post step which have no effect #2031

Open
@npalm

Description

The checkout action allows to set set-safe-directory, which is by default set to true. Which according to the docs will configure git to set the current working directory as a safe directory. However, this step is only executed is post job step.

To me this seems have no usages, since after the the post step the job is done and context gone (for ephemeral runners). Wondering if this intenstional or a potential bug. In case it is not a bug it is at least a short coming in the docs. The docs are not mentioning the safe-directory is confiugred as post step at all. The file get-source-provider.ts hints that the function is avaiable for using the checkout aciton in a container job which is exactly our use case.

In our case we run the following

  job:
    runs-on: [ubuntu-latest]
    container: node:20.17-bookworm
    steps:
      - name: Checkout
        uses: actions/checkout

      - name: Check git
         run: |
           git config --list

           ### RESULT not safe directory set

      - name: Prettier
        run: yarn prettier:write

      - name: suggester / prettier
        uses: reviewdog/action-suggester
        with:
          tool_name: prettier
          filter_mode: nofilter
          

In this case the action reviewdog/action-suggester is failing with errors not a git direcotry. When we add in the setp Check git run a git config --global -add safe.directory WORKS_SPACE_DIR. All works fine. We see in the post step the eheckout action is setting the safe directory, but this has no effect anymore.

Please can you explain what the intention is of the set-safe-directroy parameter, and or if it could be a bug that it is running as post step.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions