Interview Prep/CI/CD/GitHub Actions

How do you write a composite action?

IntermediateConceptGitHub Actions
Answer

Create action.yml in a directory (for example .github/actions/setup-app/) and use it with a local path.

# .github/actions/setup-app/action.yml
name: Setup app
inputs:
  node-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
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-app

Checkout must happen first for local actions to exist.

All CI/CD questions

More on GitHub Actions