This Week I Discovered

Happy Git repositories are all alike; every unhappy Git repository is unhappy in its own way. —Linus Tolstoy

Tools

Opensouce tools:

Commercial tools:

Projects

This Week I Learned

GitHub Actions workflow in Gmeek project

Gmeek workflow file is here

Part 1, Events that trigger workflows used by Gmeek

  1. workflow_dispatch: manual operation would trigger the flow.
  2. issues: issue events would trigger the flow.
  3. schedule: trigger the workflow at a scheduled time.
Some of the events would also be recorded in the GitHub Webhook payload. After triggering the flow, some of the flow [variables](https://docs.github.com/en/actions/learn-github-actions/variables) would be changed.
Webhook event payload Activity types GITHUB_SHA after triggering GITHUB_REF after triggering
workflow_dispatch Not applicable Last commit on the GITHUB_REF branch or tag Branch or tag that received dispatch
Not applicable Not applicable Last commit on default branch Default branch
issues opened
edited
deleted
transferred
pinned
unpinned
closed
reopened
assigned
unassigned
labeled
unlabeled
locked
unlocked
milestoned
demilestoned
Last commit on default branch Default branch

Part 2, Actions from GitHub Marketplace

  1. checkout@v4, this action on default fetch the single commit on $GITHUB_REF/$GITHUB_SHA .
  2. configure-pages@v4, this action on default enables Pages and extracts various metadata about the site.
  3. setup-python@v5, this action setups Python environment including specific Python version, pack manager, and finally sets the path.
  4. upload-pages-artifact@v3, this action composite the static assets to be deployed on GitHub Pages using tar command.
  5. deploy-pages@v4, this action deploys the artifact uploaded in the action above.

All the workflows that build the repository and publish it to GitHub Pages commonly use the actions above, and GitHub provides a starter-workflow.

Part 3, Other jobs

  1. Cloning the generator script and templates
    • the author uses jq command to parse GMEEK_VERSION and decide which version to clone.
  2. Parsing configurations
    • the author uses json package in the Python script to use other configurations, then generate HTMLs.
  3. Generate the blogs
    • the author created a GMEEK class, it contains all the members and methods for creating the static assets
      • important members: options, user
      • important methods:
        • defaultConfig(), this function reads configs from config.json.
        • markdown2html(mdstr), calls github's markdown api to get html.
        • renderHtml(template, blogBase, postListJson, htmlDir, icon), loads templates and render the final html file.
        • createPostHtml(issue), opens .md file, gets .html output by calling markdown2html(), checks MathJax and alerts, configs the post info, render the final .html by calling renderHtml().
  4. Commit and push to the repository.

JSON format and jq command

I've been wrong about understanding JSON format for a long time, almost every programming language supports JSON.

JSON is a data-interchange format, a JSON object is an unordered set of name/value pairs seperated by comma.

jq usage: jq tutorial, the tutorial takes jq's GitHub repository as example to show how the command should be use.

This Week I Built

A Blog

Blog site: immelon.top, thanks to Gmeek.

Gmeek uses GitHub Actions to render issues into HTMLs, then GitHub Pages render the repository on the <username>.github.io, comments on the issues would be rendered into comment widget of the blog by utterance

There are several other projects follows the road above(or similarily), they are different to some extent:

  1. Gitblog | Lightweight Blogging Solution, many more themes, provides analytics, needs to be paid for more than one blog under one account and API access(to analytics?).
  2. yihong0618/gitblog: People Die, but Long Live GitHub, opensource, but many complex configurations.
  3. GitHub - imuncle/gitblog, integrates configuration into one file, provides API access to the blog.

Which aspect of Gmeek attracts me most?

  1. Easy and fast, two-step configuration based on GitHub template repository, I can even configure nothing to start writing!
  2. Primer style UI, github's stable and pretty design system.
Thanks for reading, comments are welcome. ❤