/template-repository-usage-action

A GitHub action to automatically update a template repository README with a list of repos that used it in an organisation.

Primary LanguageTypeScriptMIT LicenseMIT

typescript-action status

Template Repository Usage GitHub Action

A GitHub action to automatically update a template repository README with a list of repos that used it in an organisation.

How to use

  1. Specify somewhere in a README that you want the list, and add:
<!-- EXAMPLE_TEMPLATE_LIST_START -->
<!-- EXAMPLE_TEMPLATE_LIST_END -->

Removing the EXAMPLE_ prefix, done here so the example below doesn't match the text above.

  1. Add the GitHub action, and set it to run nightly

Options

Option Required Description
token A personal access token that can access your organisation repos, see here for more.
org A way to override the organisation the action is checking for usage of the template, otherwise it uses the org that owns the repo where the action is running.
repo A way to override the repo the action is checking for usage of in the given org, otherwise it uses the repo where the action is running.
readme_path The path to the README to update.
heading_level The heading level for the usage section in the README file. (default: 1)
author_name The name of the user that will be displayed as the author of the commit.
author_email The email of the user that will be displayed as the author of the commit.
cwd The directory where your repository is located. You should use actions/checkout first to set it up.

Code in Main

Install the dependencies

$ npm install

Build the typescript and package it for distribution

$ npm run build && npm run package

Run the tests ✔️

$ npm test

 PASS  ./index.test.js
  ✓ throws invalid number (3ms)
  ✓ wait 500 ms (504ms)
  ✓ test runs (95ms)

...

Publish to a distribution branch

Actions are run from GitHub repos so we will checkin the packed dist folder.

Then run ncc and push the results:

$ npm run package
$ git add dist
$ git commit -a -m "prod dependencies"
$ git push origin releases/v1

The action is now published! 🚀

See the versioning documentation

Validate

You can now validate the action by referencing ./ in a workflow in your repo (see test.yml)

uses: ./
with:
  milliseconds: 1000

See the actions tab for runs of this action! 🚀

Usage:

After testing you can create a v1 tag to reference the stable and latest V1 action

Example:

22 Repositories using next-template