How I Prefer to Write GitHub Workflows

Check Out the Zustand Case

Hi,

Today’s topic is about GitHub workflows. As always, I prefer things short. Let’s take a look at one of the workflows in the Zustand repository:

name: Test

on:
  push:
    branches: [main]
  pull_request:
    types: [opened, synchronize]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: pnpm/action-setup@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 'lts/*'
          cache: 'pnpm'
      - run: pnpm install
      - run: pnpm run test:format
      - run: pnpm run test:types
      - run: pnpm run test:lint
      - run: pnpm run test:spec
      - run: pnpm run build # we don't have any other workflows to test build

You might notice that I avoid using name: in steps. Often, I see workflow examples like this:

  - name: Install
    run: pnpm install

While adding name: may improve readability in GitHub’s UI, I find that the bare command is already clear enough. So my preference looks like this:

  - run: pnpm install

It's a small detail, but I wanted to share that it works just fine—and keeps things a little cleaner for me.

Happy coding.

Reply

or to participate.