Skip to content
Latchkey

build-pipeline workflow (ml-tooling/lazydocs)

The build-pipeline workflow from ml-tooling/lazydocs, explained and optimized by Latchkey.

C

CI health: C - fair

Point runs-on at Latchkey and get run de-duplication, job timeouts, self-healing for flaky steps, and up to 58% lower cost, applied automatically.

Grade your own workflow free or run it on Latchkey →
Source: ml-tooling/lazydocs.github/workflows/build-pipeline.ymlLicense MITView source

What it does

This is the build-pipeline workflow from the ml-tooling/lazydocs repository, a real project running GitHub Actions. It is shown here with attribution under its MIT license.

Below, Latchkey shows a faster, safer version produced by its optimization engine.

The workflow

workflow (.yml)
# Based on https://github.com/ml-tooling/universal-build/blob/v0.6.12/workflows/build-pipeline.yml
name: build-pipeline

on:
  workflow_dispatch:
    inputs:
      build_args:
        description: "Arguments passed to build script"
        required: false
      working_directory:
        description: "Working directory from where the build command is run"
        required: false
  push:
  pull_request:

env:
  BUILD_ARGS: ${{ secrets.BUILD_ARGS }}
  WORKING_DIRECTORY: ${{ secrets.WORKING_DIRECTORY }}

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: set-input-build-args
        if: ${{ github.event.inputs != null  &&  github.event.inputs.build_args != null}}
        run: echo "BUILD_ARGS=${{ github.event.inputs.build_args }}" >> $GITHUB_ENV
        # new syntax: run: echo "BUILD_ARGS=${{ github.event.inputs.build_args }}" >> "$GITHUB_ENV"
      - name: set-input-working-directory
        if: ${{ github.event.inputs != null  &&  github.event.inputs.working_directory != null}}
        run: echo "WORKING_DIRECTORY=${{ github.event.inputs.working_directory }}" >> $GITHUB_ENV
        # new syntax: run: echo "WORKING_DIRECTORY=${{ github.event.inputs.working_directory }}" >> "$GITHUB_ENV"
      # Set host ip to env variable to be uside within container actions
      - name: set-host-ip
        run: echo "_HOST_IP=$(hostname -I | cut -d ' ' -f 1)" >> $GITHUB_ENV
      - uses: actions/checkout@v2
      - name: run-build-scripts
        uses: ./.github/actions/build-environment
        with:
          build_args: ${{ env.BUILD_ARGS }}
          working_directory: ${{ env.WORKING_DIRECTORY }}
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

The same workflow, on Latchkey

Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.

# Based on https://github.com/ml-tooling/universal-build/blob/v0.6.12/workflows/build-pipeline.yml
name: build-pipeline
 
on:
  workflow_dispatch:
    inputs:
      build_args:
        description: "Arguments passed to build script"
        required: false
      working_directory:
        description: "Working directory from where the build command is run"
        required: false
  push:
  pull_request:
 
env:
  BUILD_ARGS: ${{ secrets.BUILD_ARGS }}
  WORKING_DIRECTORY: ${{ secrets.WORKING_DIRECTORY }}
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  build:
    timeout-minutes: 30
    runs-on: latchkey-small
    steps:
      - name: set-input-build-args
        if: ${{ github.event.inputs != null  &&  github.event.inputs.build_args != null}}
        run: echo "BUILD_ARGS=${{ github.event.inputs.build_args }}" >> $GITHUB_ENV
        # new syntax: run: echo "BUILD_ARGS=${{ github.event.inputs.build_args }}" >> "$GITHUB_ENV"
      - name: set-input-working-directory
        if: ${{ github.event.inputs != null  &&  github.event.inputs.working_directory != null}}
        run: echo "WORKING_DIRECTORY=${{ github.event.inputs.working_directory }}" >> $GITHUB_ENV
        # new syntax: run: echo "WORKING_DIRECTORY=${{ github.event.inputs.working_directory }}" >> "$GITHUB_ENV"
      # Set host ip to env variable to be uside within container actions
      - name: set-host-ip
        run: echo "_HOST_IP=$(hostname -I | cut -d ' ' -f 1)" >> $GITHUB_ENV
      - uses: actions/checkout@v2
      - name: run-build-scripts
        uses: ./.github/actions/build-environment
        with:
          build_args: ${{ env.BUILD_ARGS }}
          working_directory: ${{ env.WORKING_DIRECTORY }}
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
 

What changed

This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.

Actions used in this workflow