Welcome to my field notes!

Field notes are notes I leave myself as I go through my day to day work. The hope is that other people will also find these notes useful. Note that these notes are unfiltered and unverified.

Restoring modification timestamps in cloned git repos

continuous integration
continuous deployment
github actions

TJ Palanca


August 7, 2022

I have a GitHub Actions Workflow that clones the repo, renders the content, then pushes it up to the gh-pages branch to be published. However, the ordering of the field notes was dependent on the file modicaition timestamps. I imagine workflows that use Make will also be affected by this issue.

I needed a solution that restored the modification timestamps after the repo is cloned. I chanced upon git-tools which contained a utility called git-restore-mtime that served this purpose perfectly. I just needed to add a step to install and execute after cloning, and ensure that the checkout action cloned the full repo by setting fetch-depth to 01.

  • 1 I presume that the modification times are taken from the git log, but I may be mistaken.

  • - name: Check out repository
      uses: actions/[email protected]
        fetch-depth: 0
    - name: Restore modification timestamps 
      run: sudo apt-get install -y git-restore-mtime && git restore-mtime

    Note that this requires git and a modern python version. GitHub Actions does come with Python preinstalled, so this works well.