How to Create a Composite Action in GitHub Actions
A composite action packages multiple steps behind a single uses reference you can share across repos.
Create an action.yml with runs.using: composite and a steps: list. Call it from any workflow with uses: pointing at the action path.
Steps
- Create
action.ymlin a folder (e.g..github/actions/setup). - Set
runs.using: compositeand liststeps:. - Declare
inputs:and reference them as${{ inputs.<name> }}.
action.yml
.github/actions/setup/action.yml
name: 'Setup project'
inputs:
node-version:
default: '20'
runs:
using: composite
steps:
- uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}
- run: npm ci
shell: bashGotchas
- Every
run:step in a composite action must declare ashell:. - Reference the action with
uses: ./.github/actions/setupfrom a workflow.
Related guides
How to Reuse a Workflow With workflow_call in GitHub ActionsBuild a reusable GitHub Actions workflow with on.workflow_call, declaring inputs and secrets, then call it fr…
How to Set the Default Shell in GitHub ActionsPin the shell for every run step in GitHub Actions with defaults.run.shell, so scripts behave consistently ac…