How to auto-generate a new directory template using GitHub Actions

A common request in the Microsoft WhatTheHack (WTH) repo is for authors to be able to easily create a new WhatTheHack template to get started.

There are some common things that all WhatTheHack repos need.

  • Need to follow directory structure (example)
    • Coach
      • Solutions
    • Student
      • Resources
  • Need Challenge & Solution Markdown files (example)
    • Coach
      • Solution-01.md
      • Solution-02.md
    • Student
      • Challenge-01.md
      • Challenge-02.md
  • Need a root README.md file
  • Need a table of contents & navigation links in each Markdown file

An example of the navigation links would look something like this

To make this easy for a new WTH author, I wrote a simple GitHub Action Workflow that can autogenerate this template.

The specific steps for the job are:

  1. Create a new Git branch for the author to start with
  2. Generate the WhatTheHack template stubs
  3. Push to new Git branch to the GitHub repo

These are encoded into a GitHub Action Workflow.

The template is generated via a bash shell script.

How to use

To generate a new WTH template, the author simply has to run the GitHub Action workflow “Create a new hack”.

Link to the GitHub repo that has the code to generate the template & the workflow.

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *