gitgithubgithub-actionscommitizen

Github Action fails: 'git-lfs' is not on your path


I am using the following Github action:

name: Python application

on:
  push:
    branches: [ "master" ]

permissions:
  contents: read

jobs:
  bump_version:
    if: "!startsWith(github.event.head_commit.message, 'bump:')"
    runs-on: ubuntu-latest
    name: "Bump version and create changelog with commitizen"
    steps:
      - name: Check out
        uses: actions/checkout@v2
        with:
          fetch-depth: 0
          token: "${{ secrets.PERSONAL_ACCESS_TOKEN }}"
      - id: cz
        name: Create bump and changelog
        uses: commitizen-tools/commitizen-action@master
        with:
          github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
          lfs: true
      - name: Print Version
        run: echo "Bumped to version ${{ steps.cz.outputs.version }}"

The step cz that makes a commit has the option lfs: true but when the Github action is executing I get the following error:

Current branch master is up to date.

This repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting '.git/hooks/pre-push'.

error: failed to push some refs to 

How to can I solve this error in order to allow that cz makes a commit?


Solution

  • Try passing the lfs: true parameter to the checkout action and then explicitly checkout LFS files:

    steps:
      - uses: actions/checkout@v3
        with:
          lfs: true
    
      - name: Checkout LFS objects
        run: git lfs checkout
    

    According to the actions/checkout documentation:

    # Whether to download Git-LFS files
    # Default: false
    lfs: ''
    

    git lfs checkout - downloads and checkouts large files from a Git LFS repository.

    In addition, there is a GH Action that provides a caching mechanism for LFS files - Cached LFS checkout.

    Additional references: