Note_Tech

All technological notes.


Project maintained by simonangel-fong Hosted on GitHub Pages — Theme by mattgraham

GitHub Actions: Execution Flow

Back


Control Execution Flow

Step Execution


Job Execution


Lab: Control Execution Flow

name: 10 - Execution Flow

on:
  workflow_dispatch:
    inputs:
      pass-unit-test:
        type: boolean
        description: whether unit tests pass
        default: true

jobs:
  lint-build:
    runs-on: ubuntu-latest
    steps:
      - name: lint and build
        run: echo "Lint and build"

  unit-test:
    runs-on: ubuntu-latest
    # continue-on-error: true
    steps:
      - name: unit test
        run: echo "running unit test"
      - name: failing tests
        if: $
        run: exit 1
  deploy-stage:
    runs-on: ubuntu-latest
    needs:
      - lint-build
      - unit-test
    steps:
      - name: Deploy stage
        run: echo "Deploy stage"
  e2e-test:
    runs-on: ubuntu-latest
    needs:
      - deploy-stage
    steps:
      - name: end-to-end test
        run: echo "e2e test"
  load-test:
    runs-on: ubuntu-latest
    needs:
      - deploy-stage
    steps:
      - name: load test
        run: echo "load test"
  deploy-prod:
    runs-on: ubuntu-latest
    needs:
      - e2e-test
      - load-test
    steps:
      - name: deploy prod
        run: echo "deploy prod"

pic


Matrices

name: My NPM package workflow
on: push
jobs:
  backwards-compatibility:
    name: $-$
    runs-on: $
    strategy:
      matrix:
        node: [14, 16, 18]
        os:
          - ubuntu-latest
          - macos-latest
          - windows-latest
    steps:
      - uses: actions/setup-node@v3
        with:
          node-version: $

Lab: Matrix

name: 15 - matrices

on:
  workflow_dispatch:

jobs:
  backwards-compatibility:
    name: $ - $
    runs-on: $
    strategy:
      fail-fast: false
      matrix:
        node-version: [22.x, 23.x, 24.x]
        os:
          - ubuntu-latest
          - windows-latest
        include:
          - os: ubuntu-latest
            node-version: 20.x
            tag: beta
    steps:
      - name: Setup node
        uses: actions/setup-node@v6
        with:
          node-version: $

      - name: Fails a version
        if: $
        run: exit 1

      - name: Execute testing
        run: echo "Testing against on OS $" and Node.js $

pic

fail-fast: false matrix.include

pic

fail-fast: true


Lab: Matrix Exclude

name: 15 - matrices exclude

on:
  workflow_dispatch:

jobs:
  backwards-compatibility:
    name: $ - $
    runs-on: $
    strategy:
      # fail-fast: false
      matrix:
        node-version: [ 22.x, 23.x, 24.x ]
        os:
          - ubuntu-latest
          - windows-latest
        exclude:
          - os: windows-latest
            node-version: 23.x
    steps:
      - name: Setup node
        uses: actions/setup-node@v6
        with:
          node-version: $

      - name: Execute testing
        run: echo "Testing against on OS $" and Node.js $

pic