Write a minimal composite action that installs Node and dependencies with caching.
IntermediateConceptCustom Actions & Reusable Workflows
Answer
.github/actions/setup-app/action.yml:
name: Setup app
description: Install Node and npm dependencies with cache
inputs:
node-version:
description: Node.js version
default: "22"
runs:
using: composite
steps:
- uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}
cache: npm
- run: npm ci
shell: bash
Use with - uses: ./.github/actions/setup-app after actions/checkout. Every run step in a composite action must declare shell.
More on Custom Actions & Reusable Workflows
What are the three kinds of custom action and how do you choose?BeginnerWhat can a composite action not do compared to a job?IntermediateHow do you pass outputs out of a composite action?IntermediateWhat does `action.yml` contain for a JavaScript action?IntermediateWhy must a JavaScript action commit its `dist/` or `node_modules`?IntermediateShow the core of a JavaScript action using the toolkit.Advanced