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

Action to fetch repo data for publishing to the blog #3

Open
wants to merge 34 commits into
base: main
Choose a base branch
from

Conversation

petronbot
Copy link

@petronbot petronbot commented Aug 11, 2021

This workflow action takes advantage of the Flat Data project to fetch data on a schedule so that it can be incorporated into the blog site's content.

Todo

  • Create a query to fetch: Code of conduct, Latest issues, Latest pull requests
  • Configure workflow to run on push events
  • Configure workflow to query Github GraphQL API
  • Configure workflow to save data response to ./src/data/repo-data.json
  • Test workflow
  • Create pages/UI to display data on the blog

flat-data and others added 6 commits August 11, 2021 01:02
{
  "date": "2021-08-11T01:02:49.166Z",
  "files": [
    {
      "name": "src/data/repo-data.json",
      "deltaBytes": 106,
      "source": "https://api.github.com/graphql"
    }
  ]
}
{
  "date": "2021-08-11T01:27:24.536Z",
  "files": [
    {
      "name": "repo-data-response.json",
      "deltaBytes": 102,
      "source": "https://api.github.com/graphql"
    }
  ]
}
{
  "date": "2021-08-11T01:33:23.386Z",
  "files": [
    {
      "name": "repo-data-response.json",
      "deltaBytes": 994,
      "source": "https://api.github.com/graphql"
    }
  ]
}
@petronbot
Copy link
Author

petronbot commented Aug 12, 2021

@elisechant this is now ready to review.

  1. The new Fetch repo data Workflow Action .github/workflows/repo-data.yml is scheduled to run on push events and open pull requests on the main branch
  2. The Action fetches data from the Github GraphQL API using the query in .github/workflows/repo-data-query.json
  3. Fetched data is saved to src/data/repoData.json where it's accessible to templates
  4. Repo data is displayed on the blog home page using the new include src/includes/contributor-activity.njk

Copy link
Contributor

@elisechant elisechant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks useful. I like how this creates information about community activity.

I assume there's no data at the moment, as there is no activity on that repo yet?

Regarding screenshot below, I propose moving "View All Posts" higher to posts, or creating more space above "Recent contributor...".

Also, perhaps we add a title above posts "Recent posts" in the same weight as "Recent contributor..."? 🎨

Screen Shot 2021-08-12 at 3 02 23 pm

@@ -0,0 +1,6 @@
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we format this file at all?

let response;

try {
json = await Deno.readFile("src/data/repoData.json");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there an advantage to using Deno here?

uses: githubocto/flat@v3
with:
http_url: https://api.github.com/graphql
downloaded_filename: src/data/repoData.json
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I propose renaming this to repo.json

try {
await Deno.writeFile(
"src/data/repoData.json",
encoder.encode(JSON.stringify(response.data.repository))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional, but for it to remain clear that this file is generated, you could prepend a comment at the top of file? maybe it would also include the generated date.

</li>
{% endfor %}
</ul>
<p><a href="">View all open issues</a></p>
Copy link
Contributor

@elisechant elisechant Aug 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing an href value here and in corresponding one below.

<div class="contributor-activity__wrapper">
<h4 class="au-display-md">Latest issue updates</h4>
<ul class="contributor-activity__list">
{% for issue in repoData.issues.nodes %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this list need limiting?

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

Successfully merging this pull request may close these issues.

3 participants