timvink / mkdocs-git-revision-date-localized-plugin

MkDocs plugin to add a last updated date to your site pages
https://timvink.github.io/mkdocs-git-revision-date-localized-plugin/index.html
MIT License
208 stars 45 forks source link

Both creation & last modified dates on all tracked files keep updating to the date/time of last commit. #140

Closed rmscode closed 5 months ago

rmscode commented 5 months ago

I just noticed this today. On github pages, all my pages are showing a date/time that matches my last commit from this afternoon. My local builds do not exhibit the same behavior...They are accurate.

timvink commented 5 months ago

Are you talking about the creation date? --> Have a look at the note on build systems in the docs (https://timvink.github.io/mkdocs-git-revision-date-localized-plugin/index.html). github does not fetch all commit history by default

Are you talking about the last modified date? --> Do you have the fallback_to_build_date option (docs) enabled?

rmscode commented 5 months ago

Update: Added fetch-depth: 0, but it made no difference.

Sorry, I was in a bit of a rush.

Yes, I meant the creation date and the last modified date.

image

I do not have fallback_to_build_date enabled.

Here are the current plugin options:

- git-revision-date-localized:
      enable_creation_date: true
      type: datetime
      timezone: America/New_York
      exclude:
        - index.md
        - notes/*

This is my github actions config:

name: mydocs-gh-pages-deploy 
on:
  push:
    branches:
      - main
permissions:
  contents: write
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Configure Git Credentials
        run: |
          git config user.name github-actions[bot]
          git config user.email 74937203+github-actions[bot]@users.noreply.github.com
      - uses: actions/setup-python@v4
        with:
          python-version: 3.x
      - run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV 
      - uses: actions/cache@v3
        with:
          key: mkdocs-material-${{ env.cache_id }}
          path: .cache
          restore-keys: |
            mkdocs-material-
      - run: pip install mkdocs-material 
      - run: pip install mkdocs-encryptcontent-plugin
      - run: pip install mkdocs-git-revision-date-localized-plugin
      - run: pip install mkdocs-git-latest-changes-plugin
      - run: mkdocs gh-deploy --force
timvink commented 5 months ago

So many build systems do not fetch the full commit history (for obvious reasons). You need to configure that explicitly, see the documentation note on build systems in the docs: https://timvink.github.io/mkdocs-git-revision-date-localized-plugin/index.html#note-when-using-build-environments

You're the third person this week hitting this; I will try to make that section in the docs easier to find.

rmscode commented 5 months ago

Thank you. You did point that out earlier and I did try fetch-depth to 0, but it hasn't changed anything. Maybe I placed that param in the wrong part of my actions config?

name: mydocs-gh-pages-deploy 
on:
  push:
    branches:
      - main
permissions:
  contents: write
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Configure Git Credentials
        run: |
          git config user.name github-actions[bot]
          git config user.email 74937203+github-actions[bot]@users.noreply.github.com
      - uses: actions/setup-python@v4
        with:
          fetch-depth: 0 # <------ HERE?
          python-version: 3.x
      - run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV 
      - uses: actions/cache@v3
        with:
          key: mkdocs-material-${{ env.cache_id }}
          path: .cache
          restore-keys: |
            mkdocs-material-
      - run: pip install mkdocs-material 
      - run: pip install mkdocs-encryptcontent-plugin
      - run: pip install mkdocs-git-revision-date-localized-plugin
      - run: pip install mkdocs-git-latest-changes-plugin
      - run: mkdocs gh-deploy --force
timvink commented 5 months ago

No on checkout actions. Docs: https://github.com/actions/checkout

rmscode commented 5 months ago

Oh crap...I did have it in the wrong area. When I read the docs, I saw that it needed to be nested under - uses: actions/checkout@v4, but my eyes must have seen the actions/ bit of - uses: actions/setup-python@v4 and I placed it there. Whoops.

Thanks for the help.