uses degit to fetch any repository or specific YAML file/folder within it. Below you can find some examples using the workflows in fregante/ghatemplates.
$ ghat --help
Description
Reuse GitHub Actions workflows across repositories
Usage
$ ghat [options]
Options
--exclude Any part of the YAML file to be removed (can be repeated)
--set Value to add (can be repeated). The value is interpreted as YAML/JSON. Writing JSON on the CLI is tricky, so you might want to wrap the whole flag value
-v, --version Displays current version
-h, --help Displays this message
files at the top level. If none are found, it will assume you want to copy the repo’s active workflows from
.github/workflows
npx ghat fregante/ghat
# Copies *.yml OR .github/workflows/*.yml
Fetch whole folder
npx ghat fregante/ghatemplates/node
# Copies node/*.yml into the local .github/workflows. It's NOT recursive
Fetch specific file
npx ghat fregante/ghatemplates/node/ci.yml
# Copies node/ci.yml into the local .github/workflows/ci.yml
Customization
Exclude properties
You can exclude any property from the template by using the
--exclude
flag, multiple times.
path
is parsed by dot-prop, so refer to its documentation.
--exclude on.schedule
Set properties
You can set/overwrite any value with the
--set =
flag, multiple times.
path
is parsed by dot-prop, so refer to its documentation.
value
is a YAML/JSON value passed directly to the YAML parser.
Note: writing JSON on the command line is a little tricky, so if you're running into errors, try wrapping the whole flag value into a string, for example:
--set 'on.schedule=[{"cron": "42 17 * * 4"}]'
env
object
When you fetch a workflow that already exists locally, the local file will be overridden, except for the top-level
env
object. For example:
Local file
env:
ADJECTIVE: cool
DO NOT EDIT BELOW - use npx ghat fregante/workflows/demo
jobs:
test:
runs-on: ubuntu-latest
steps:
- run: echo My workflow is $ADJECTIVE
Template file
env:
ADJECTIVE: the default
jobs:
test:
runs-on: ubuntu-latest
steps:
- run: echo This new workflow is "$ADJECTIVE" since it was updated
Updated local file
Only the top-level
env
will be preserved, the rest will be updated.
env:
ADJECTIVE: cool
DO NOT EDIT BELOW - use npx ghat fregante/workflows/demo
jobs:
test:
runs-on: ubuntu-latest
steps:
- run: echo This new workflow is "$ADJECTIVE" since it was updated
We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.