Problems with GitInfo in CI

By default, the GitHub “checkout” action only fetches a single commit (for the ref/SHA that triggered the workflow). This results in the behavior you describe – i.e. the current date/time is used for .Lastmod.

If you modify the checkout action to fetch the entire history (by specifying fetch-depth: 0), then .GitInfo and .Lastmod works as expected:

jobs:
  build_and_deploy_job:
    ...
    steps:
      - uses: actions/checkout@v2
        with:
          ...
          fetch-depth: 0    # Fetch all history for .GitInfo and .Lastmod