Package: actions-includes
:warning: This project ismostlyabandoned.You are probably better usingComposite ActionsorReusable workflows.actions-includesAllows including an action inside another action (by preprocessing the YAML file).Instead of usingusesorrunin your action step, use the keywordincludes.Once you are using theincludesargument, the workflows can be expanded using this tool as follows:# python -m actions_include <input-workflow-with-includes> <output-workflow-flattened>python-mactions_includes./.github/workflows-src/workflow-a.yml./.github/workflows/workflow-a.ymlUsage with dockerdockercontainerrun--rm-it-v$(pwd):/github/workspace--entrypoint=""ghcr.io/mithro/actions-includes/image:mainpython-mactions_includes./.github/workflows-src/workflow-a.yml./.github/workflows/workflow-a.ymlincludes:stepsteps:-name:Other steprun:|command-includes:{action-name}with:{inputs}-name:Other steprun:|commandThe{action-name}follows the same syntax as the standard GitHub actionusesand the action referenced should look exactly like aGitHub "composite action"exceptruns.usingshould beincludes.For example;{owner}/{repo}@{ref}- Public action ingithub.com/{owner}/{repo}{owner}/{repo}/{path}@{ref}- Public action under{path}ingithub.com/{owner}/{repo}../{path}- Local action under local{path}, IE./.github/actions/{action-name}.As it only makes sense to reference composite actions, thedocker://form isn't supported.As you frequently want to include local actions,actions-includesextends the{action-name}syntax to also support:/{name}- Local action under./.github/includes/actions/{name}.This is how composite actions should have worked.includes-script:You can include a script (e.g., a Python or shell script) in your workflow.yml file using theincludes-scriptstep.Example script file:script.pyprint('Hello world')To include the script, reference it in anincludes-scriptaction in yourworkflow.yml, like so:steps:-name:Other steprun:|command-name:Helloincludes-script:script.py-name:Other steprun:|commandWhen the workflow.yml is processed by runningpython -m actions_includes.py workflow.in.yml workflow.out.yml,
the resultantworkflow.out.ymllooks like this:steps:-name:Other steprun:|command-name:Helloshell:pythonrun:|print('Hello world')-name:Other steprun:|commandTheshellparameter is deduced from the file extension,
but it is possible to use a custom shell by setting theshellparameter manually.Using a pre-commit hookWhen you use actions-includes, it may be useful to add a pre-commit hook
(seehttps://git-scm.com/docs/githooks) to your project so that your workflow
files are always pre-processed before they reach GitHub.With a git hooks packageThere are multiple packages (notablypre-commit;
seehttps://pre-commit.com/) that support adding pre-commit hooks.In the case of using thepre-commitpackage, you can add an entry
such as the following to yourpre-commit-config.yamlfile:- repo: local
  hooks:
  - id: preprocess-workflows
    name: Preprocess workflow.yml
    entry: python -m actions_includes.py workflow.in.yml workflow.out.yml
    language: system
    always-run: trueWithout a git hooks packageAlternatively, to add a pre-commit hook without installing another
package, you can simply create or modify.git/hooks/pre-commit(relative to your project root). A sample file typically
lives at.git/hooks/pre-commit.sample.The pre-commit hook should run the commands that are necessary to
pre-process your workflows. So, your.git/hooks/pre-commitfile
might look something like this:#!/bin/bashpython-mactions_includes.pyworkflow.in.ymlworkflow.out.yml||{echo"Failed to preprocess workflow file."""}To track this script in source code management, you'll have to
put it in a non-ignored file in your project that is then copied to.git/hooks/pre-commitas part of your project setup. Seehttps://github.com/ModularHistory/modularhistoryfor an example
of a project that does this with a setup script (setup.sh).