Skip to content

last-modified is not working as expected when rendering on github actions as Git does not store last modified date #5967

Open

Description

@cderv

In a github action rendering, there will be a checkout at each rendering. This implies that the last modified date of each file will be the same as the git checkout date. This is because of the fact that git does not store last modified date information.

There are workaround to restore date of file to last commit date for the files:

Maybe we could try be clever when inside a git project, or leverage the _freeze state for project to store information.

Discussed in #5899

Originally posted by adityam June 13, 2023

Description

I am using github actions to publish my website.

  1. Website: https://adityam.github.io/stochastic-control/
  2. Github action: https://github.com/adityam/stochastic-control/blob/quarto/.github/workflows/quarto-render.yml

In _quarto.yml, I have set

format:
  html:
    published-title: Updated
    date: last-modified

but all my pages have today's date.

I suspect that the last modified date is coming from the date the date when github CI clones the repo (and hence today's date) rather than when the file was checked into the repo (which is the true last-modified date).

Is it possible to somehow use the date when the file was last committed to git, for example, similar to what is available for hugo

Activity

  1. added this to the Future milestone on Jun 19, 2023
  2. maptv commented on Dec 3, 2023

    @maptv

    I have this same problem.
    There are two relevant solutions provided on SO.
    I’m going to try resolving this issue with this GitHub Action.

  3. maptv commented on Dec 3, 2023

    @maptv

    I see now that there’s already a solution in the associated discussion: #5899 (reply in thread)

  4. jolars commented on May 31, 2024

    @jolars
    Contributor

    Did you get this to work? I have tried the script at #5899 (and this one too), as well as the github action, but I still don't get this to work.

    Could it be related to the workflow initiated by github when the website is pushed to the gh-pages branch includes a checkout?

  5. maptv commented on May 31, 2024

    @maptv

    For now, I am just using quarto publish locally, but still intend to figure this out when I have time. I was writing a blog post on using git and this issue prompted me to pause working on it and then I got busy with other things.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions