Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cloudflare Pages fetch-depth #123

Closed
segg21 opened this issue Oct 19, 2023 · 6 comments
Closed

Cloudflare Pages fetch-depth #123

segg21 opened this issue Oct 19, 2023 · 6 comments

Comments

@segg21
Copy link

segg21 commented Oct 19, 2023

I'm currently trying to figure out how with cloudflare pages to fix the fetch-depth issue.
Cloudflare is automatically doing the deployment/pipeline without any github workflow files.

I'm not sure how to fix this issue so that file created timestamps are proper, not from last commit date.

Thanks!

@segg21 segg21 closed this as completed Oct 19, 2023
@segg21 segg21 reopened this Oct 19, 2023
@timvink
Copy link
Owner

timvink commented Oct 19, 2023

Hi @segg21 ,

I am not familiar with cloudflare pages (https://pages.cloudflare.com/)

One thing you could do, is setup cloudflare pages to deploy your gh-pages branch, instead of the default branch.

Now you can use mkdocs gh-deploy --force (docs) locally to push the build to that branch automatically.
You could also use github actions to build and push to gh-pages whenever you push to master/ main, see https://squidfunk.github.io/mkdocs-material/publishing-your-site/?h=github+ac#with-github-actions (but make sure to change the git clone depth in that case). Note that mkdocs gh-deploy has an option to use a different branch name than gh-pages also.

If you really want to use cloudflare builds, I can't help you with that. I searched for you, I didn't find an option to specify clone depth.

@timvink timvink closed this as completed Oct 19, 2023
@segg21
Copy link
Author

segg21 commented Oct 19, 2023

Thanks. I ended up figuring out. I didn't want to use GitHub pages due to limitations, and the extra benefits CF pages provides.

@jdguillot
Copy link

@segg21 What ended up being your solution to this? I also am in the same situation and cannot find any documentation on how to change the fetch-depth for CF Pages.

@segg21
Copy link
Author

segg21 commented Dec 19, 2023

@segg21 What ended up being your solution to this? I also am in the same situation and cannot find any documentation on how to change the fetch-depth for CF Pages.

Instead of CloudFlare automatically detecting updates, building, and publishing itself, I'm using GitHub actions (that does building w/ fetch-depth) and pushing site contents to CloudFlare using cloudflare/pages-action@v1

Here an example of the action I have setup.

You'll need to disable GitHub automation within CloudFlare's dashboard for your page.

@jdguillot
Copy link

@segg21 What ended up being your solution to this? I also am in the same situation and cannot find any documentation on how to change the fetch-depth for CF Pages.

Instead of CloudFlare automatically detecting updates, building, and publishing itself, I'm using GitHub actions (that does building w/ fetch-depth) and pushing site contents to CloudFlare using cloudflare/pages-action@v1

Here an example of the action I have setup.

You'll need to disable GitHub automation within CloudFlare's dashboard for your page.

That makes perfect sense. Thanks for all the info! I think I'll follow your lead on this and do something similar.

@fertek
Copy link

fertek commented Mar 12, 2024

segg21's link to example doesn't work anymore, so I'm pasting here the contents of the .github/workflows/publish.yml file that works for me.

on: [push]

jobs:
  publish:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      deployments: write
    name: Publish to Cloudflare Pages
    steps:
      - name: Checkout
        uses: actions/checkout@v4
        with:
          fetch-depth: 0

      # Run a build step here if your project requires
      - name: Set up Python
        uses: actions/setup-python@v2
        with:
          python-version: '3.x'  # Set up the Python version

      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install -r requirements.txt

      - name: Build the MkDocs site
        run: mkdocs build  # Builds your documentation

      - name: Publish to Cloudflare Pages
        uses: cloudflare/pages-action@v1
        with:
          apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
          accountId: YOUR_ACCOUNT_ID
          projectName: YOUR_PROJECT_NAME
          directory: ./site
          # Optional: Enable this if you want to have GitHub Deployments triggered
          gitHubToken: ${{ secrets.GITHUB_TOKEN }}
          # Optional: Switch what branch you are publishing to.
          # By default this will be the branch which triggered this workflow
          branch: main

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants