Skip to content

Scaffolding a New Action

Tim Etchells edited this page Aug 26, 2021 · 8 revisions

New actions should use the resources available in the common repository.

All JavaScript/TypeScript actions should use the action-io-generator and bundle-verifier from the common repository. See these tools' READMEs for more context.

CI Checks

All action repositories should have a CI Checks workflow that runs on Push and Pull Request. These checks will:

  1. Run any linters (minimally, ESLint)
  2. Use bundle-verifier to test that the committed bundle is up-to-date
  3. Use action-io-generator to test that the action.yml is in sync with the Inputs and Outputs enum
  4. Run a Link Checker on all .md files.

See the action repositories such as buildah-build for practical examples of the CI checks, and the Link Checker. Write scripts that wrap these commands in the package.json for reusability, locally and in other scripts (like the pre-commit hook below).

Pre Commit Hook

It is good practice to write a pre-commit hook which runs a shell script containing the CI check scripts, so that the checks will pass when code is committed and pushed. When cloning, copy the script out into .git/hooks/pre-commit and accept overwrites.

Again, see an example in buildah-build.

Configuration Files

It is recommended to also use the TSConfig and ESLint config from the common repository. However, since these are so subjective, authors may choose to use different configuration files if they prefer, or extend ours and modify some rules.

Other Notes

  • You can use NPM or yarn, it doesn't matter. The existing actions mostly use NPM though I prefer yarn now for its better performance.
  • The Red Hat Actions are MIT Licensed.
  • Please read the brief page on Naming Guidelines in this wiki.