Consider this action that I use in my code
It looks just like a workflow, but it's actually a reusable action.
name: 'Checkout, Install Node and Dependencies'
description: 'Install dependencies'
runs:
using: 'composite'
steps:
- uses: actions/checkout@v3
name: Checkout Repository 🫠
- name: Setup Node 🏞️
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'npm'
- run: npm ci
And then in your workflow:
name: Run Unit Tests
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
unit-test:
runs-on: ubuntu-latest
steps:
- name: Checkout and Setup Node
uses: ./.github/actions/checkout-and-setup
- run: npm test
build:
runs-on: ubuntu-latest
steps:
- name: Checkout and Setup Node
uses: ./.github/actions/checkout-and-setup
- run: npm run build
This feels like it should work, right? Why won't it? Why? Why?
Hint: What's the order of operations here?