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

GitHub Module Shows Out-of-Date Metadata #6

Closed
msolters opened this issue Jun 5, 2016 · 6 comments
Closed

GitHub Module Shows Out-of-Date Metadata #6

msolters opened this issue Jun 5, 2016 · 6 comments

Comments

@msolters
Copy link

msolters commented Jun 5, 2016

When a site is deployed to GitHub pages, the GitHub module works correctly at first -- it produces a list of open source repositories, with "last modified" dates, number of stars, etc.

However, the repository data does not update on subsequent visits to the site. For example, GitHub's feed notifies me that I have received two more stars on a repo, but on my site it still shows the old number of stars, and the old "last modified" date.

I understand the purpose of Jekyll is that it renders static site content. However, I would have imagined that the GitHub module is asynchronously making GitHub API calls to get the metadata. Otherwise it would be by design constantly out-of-date!

Is there something I am doing wrong? I do get this message when I run bundle exec jekyll serve locally:

GitHub Metadata: No GitHub API authentication could be found. Some fields may be missing or have incorrect data.
@DONGChuan
Copy link
Owner

DONGChuan commented Jun 5, 2016

Here, the repository metadata is not updated immediately. It needs to wait around one day according to me. If you want "asynchronously", it needs to send AJAX call each time a client visit your page. But to say the truth (I used this way before). It takes around 0.5 to 2 seconds and github api is not as stable as you think. It is why I choose github metadata plugin here, almost no delay. I think one-day-delay for numbers of stars is ok for most of cases.

For the error you mention, I guess you tried to get some "security" fields like cname. I suggest to visit this page: https://github.com/jekyll/github-metadata. In "Authentication", you will find solution. In my code, I only choose the public fields to avoid using tokens, because I think it's dangerous to keep your token public in your source code ...

@msolters
Copy link
Author

msolters commented Jun 5, 2016

I still do not understand. I do have a CNAME file in my repo. How is that security? Secondly, what are these tokens the "Authentication" section you refer to is discussing? How are they generated?

How do environment variables in any of the proposed solutions affect the deployment to GitHub?

@DONGChuan
Copy link
Owner

First question:

According to the plugin itself, check here: https://github.com/jekyll/github-metadata. Area "For some fields, like cname, you need to authenticate yourself. ". I don't know why, but it seems that some fileds like cname need your token.

Second question:
To generate tokens. Go to --> Personal setting -> Personal access tokens.

Third question:
To use tokens, you may need to set it in your _config.yml. But I m not 100% sure. Because test on your local and test directly on github repo (so push your code on remote) are different. On your local, I think you need the token. But after pushing it on remote repo, not quite sure about it.

@msolters
Copy link
Author

msolters commented Jun 7, 2016

Interestingly, I discovered the problem I previously cited #3 is not solved by the latest Ruby. It actually only happens at a specific time of day (0000 - 0400 EDT).

When I run jekyll serve, the following line:

{% assign sorted_repos = (site.github.public_repositories | sort: 'stargazers_count') | reverse | where: "fork", "false" %}

Generates the following error:

Liquid Exception: undefined method `sort' for false:FalseClass in _includes/about.html, included in about.md

It does this every night after midnight, and in the morning, the error just disappears.

Removing the GitHub API line removes the error.

I tried changing my computer's clock time, to see if the error would go away if the localhost though it was tomorrow morning, but it did not fix anything. I wonder if there is a time window late each night GitHub's API is just down?

@DONGChuan
Copy link
Owner

WOW. First time to know it!! I did some research, but no answer.

"sort" here means "site.github.public_repositories" is null.

So I suggest to check directly msolters.github.io after midnight. If it's ok, just ignore it. Github API may have some special process hidden in the background :(

@cknightdevelopment
Copy link

If you are still experiencing this issue, I have a blog post and video showing how to fix it. The skinny of it is this:

  1. Create a personal access token in GitHub. This takes just a second, see GitHub’s documentation. When picking the scope(s) that you want to grant to the token, just select the repo checkbox.
  2. Add a new system environment variable on your machine named JEKYLL_GITHUB_TOKEN and set the value equal to the personal access token you generated.
  3. Go here, copy all the text in the page, and save it as a file named cacert.pem somewhere on your local machine.
  4. Add a new system environment variable on your machine named SSL_CERT_FILE and set the value equal to the full file path of where you saved the cacert.pem file.
  5. RESTART YOUR MACHINE (this is not optional)

The blog post assumes you are on a Windows machine, but the same steps should work on a Mac.

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

3 participants