DEV Community

Discussion on: Get changed files in github actions

Collapse
 
veotani profile image
Anton Orlov • Edited

It's because you fetch only latest commit. You can solve this issue by setting fetch-depth to 0 to retrieve full git history.

- uses: actions/checkout@v2
  with:
    fetch-depth: 0
Enter fullscreen mode Exit fullscreen mode
Collapse
 
parasense profile image
parasense

To elaborate on Anton Orlov's answer regarding fetch-depth.
To have git diff the current HEAD (depth:1) against the previous commit (depth:2), then one needs to have at least fetch-depth: 2, and if one wants to diff against deeper history one must set the depth accordingly. Many git work flows only fetch a depth:1 as an optimization, to avoid expensive IO copying entire repos when only the single commit is needed.