Staticman: v3: submitted comments show up in _data/comments. However, the website doesn't get re-built

Created on 28 Jan 2019  Â·  8Comments  Â·  Source: eduardoboucas/staticman

staticman v3 creates commits successfully (yml files appear in _data/comments), but it doesn't trigger a rebuild (correction: fails to get rebuilt — the trigger might be fine) on github pages (the deployed version remains based on the last commit created by me rather than the bot). If I manually pull and then push back, the website gets re-built, and the new comments finally become visible.

The same issue was described by @willymcallister in https://github.com/eduardoboucas/staticman/issues/243#issuecomment-454905594_:

When I submit a comment it shows up in _data/comments. However, github-pages/Jekyll does not trigger a rebuild of the parent article.

I'm using the App with the v3 endpoint, per Eduardo's edited instructions. I waited the suggested 10 minutes for github-pages to respond. If I make a trivial change to an unrelated article and push, the rebuild is triggered promptly and the comment appears.

My site is on github-pages.
https://spinningnumbers.org/a/staticman.html, https://github.com/willymcallister/willymcallister.github.io

feature request question

Most helpful comment

Oh, wow. Thanks for looking into this.

A fix would be to have the Staticman app send a pages build request through the Github API:

I'm not sure I like this approach, because Staticman doesn't know (and shouldn't care) whether you use GitHub Pages or not. Its job is to get content into your repository. I'm not keen on adding logic that is specific to GitHub Pages.

Given this limitation from the GitHub API, I don't see what's the best way to make Staticman work without moderation.

All 8 comments

Additional details:

  • The repository settings tab says "Your site is having problems building: Page build failed" under GitHub Pages after staticman adds a new comment. Once I manually pull/push, the error message goes away and the site builds just fine.

  • One example of a commit by staticman v3 that fails to deploy: https://github.com/ex-punctis/ex-punctis.github.io/commit/2009183b46f8c171314641bca39185c61a1f9b02

  • Comment test page. There is one comment that shows up because I pulled it and then pushed back. The latest comment doesn't show up because the site failed to get re-built when the comment was added by staticman.

  • Form action: "https://dev.staticman.net/v3/entry/github/ex-punctis/ex-punctis.github.io/master/comments"

  • config:
    comments:

    allowedFields: ["name", "message"]

    branch: "master"

    commitMessage: "add [comment]: by {fields.name} nn{fields.permalink}#comment-{@id}"

    filename: "comment_{@timestamp}"

    path: "_data/comments/{options.postId}"

    format: "yaml"

    generatedFields:
    date:
    type: date
    options:
    format: "timestamp-seconds"

    moderation: false

    requiredFields: ["name", "message"]

  • I thought that perhaps the issue with re-building had something to do with the code responsible for displaying the comments, so I removed it temporarily. However, submitting a new comment after that still caused a rebuild issue. So whatever the problem is, it has something to do with the way the yml comment files are added.

Edit: I have experimented with various fields/filenames/paths, and the result is always the same — when staticman pushes a comment, github reports " Your site is having problems building: Page build failed." As soon as I edit something completely unrelated and committ/push, the site builds just fine. For some reason the github pages service doesn't play nice with the staticman app.

My preliminary experimentation suggests this is due to the "moderation: false" setting; It seems like Github Pages does not force a rebuild of the website unless the owner of the repository makes a commit.

A fix would be to have the Staticman app send a pages build request through the Github API:
https://developer.github.com/v3/repos/pages/#request-a-page-build
https://stackoverflow.com/a/53842971

I'm unsure how to make this change.

@eduardoboucas

Github support looked at why my site was not rebuilding (https://spinningnumbers.org/a/staticman.html). The issue is solved by enabling moderation. Here is the full response...

It looks like your site builds are failing with the following error:
Validation failed: User must be a human
To avoid abuse, GitHub Pages sites can't be automatically rebuilt when a GitHub App pushes to a repository. As StaticMan is a GitHub App it isn't able to automatically trigger a rebuild of your site.

I notice that this application has a moderation-mode, that will create pull requests for you to merge manually. Enabling this mode will let this app create pull requests, and will then trigger a build when you manually merge them.

I'd recommend reaching out to the project maintainer for more help on this, as this will need to be something that is changed on their side.

Thanks,
Thomas
GitHub Support

Oh, wow. Thanks for looking into this.

A fix would be to have the Staticman app send a pages build request through the Github API:

I'm not sure I like this approach, because Staticman doesn't know (and shouldn't care) whether you use GitHub Pages or not. Its job is to get content into your repository. I'm not keen on adding logic that is specific to GitHub Pages.

Given this limitation from the GitHub API, I don't see what's the best way to make Staticman work without moderation.

@ex-punctis An obvious solution would be configuring your repo with a CI service.

@VincentTam Thanks for the tip, I'll look into this.

@ex-punctis Note that GitHub Actions are in beta. This includes an internal CI support. You may apply for it. Here's the template for Jekyll:
https://github.com/actions/starter-workflows/blob/dcaa948ed3751fbfc4285b4745799dc2a5d4476e/ci/jekyll.yml

As noted by other users, it should be possible to configure either GitHub Actions, or Travis to automatically rebuild your website when moderation is disabled.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lisandroct picture lisandroct  Â·  7Comments

onwingslikeeagles picture onwingslikeeagles  Â·  15Comments

zburgermeiszter picture zburgermeiszter  Â·  8Comments

robinmetral picture robinmetral  Â·  5Comments

donaldboulton picture donaldboulton  Â·  9Comments