Skip to content
Latchkey

Migration Version Check workflow (codebymitch/TitanBot)

The Migration Version Check workflow from codebymitch/TitanBot, 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: codebymitch/TitanBot.github/workflows/migration-version-check.ymlLicense MITView source

What it does

This is the Migration Version Check workflow from the codebymitch/TitanBot 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)
name: Migration Version Check

on:
  pull_request:
  push:
    branches:
      - main
      - master
      - mitchwork

jobs:
  migration-check:
    runs-on: ubuntu-latest

    services:
      postgres:
        image: postgres:16
        env:
          POSTGRES_USER: titanbot
          POSTGRES_PASSWORD: titanbot
          POSTGRES_DB: titanbot
        ports:
          - 5432:5432
        options: >-
          --health-cmd "pg_isready -U titanbot -d titanbot"
          --health-interval 10s
          --health-timeout 5s
          --health-retries 5

    env:
      POSTGRES_URL: postgresql://titanbot:titanbot@localhost:5432/titanbot
      POSTGRES_HOST: localhost
      POSTGRES_PORT: 5432
      POSTGRES_DB: titanbot
      POSTGRES_USER: titanbot
      POSTGRES_PASSWORD: titanbot
      POSTGRES_SSL: "false"
      SCHEMA_VERSION: "1"
      SCHEMA_VERSION_LABEL: "baseline-v1"

    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: 20
          cache: npm

      - name: Install dependencies
        run: npm ci

      - name: Apply migrations
        run: npm run migrate

      - name: Validate migration version
        run: npm run migrate:check

The same workflow, on Latchkey

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

name: Migration Version Check
 
on:
  pull_request:
  push:
    branches:
      - main
      - master
      - mitchwork
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  migration-check:
    timeout-minutes: 30
    runs-on: latchkey-small
 
    services:
      postgres:
        image: postgres:16
        env:
          POSTGRES_USER: titanbot
          POSTGRES_PASSWORD: titanbot
          POSTGRES_DB: titanbot
        ports:
          - 5432:5432
        options: >-
          --health-cmd "pg_isready -U titanbot -d titanbot"
          --health-interval 10s
          --health-timeout 5s
          --health-retries 5
 
    env:
      POSTGRES_URL: postgresql://titanbot:titanbot@localhost:5432/titanbot
      POSTGRES_HOST: localhost
      POSTGRES_PORT: 5432
      POSTGRES_DB: titanbot
      POSTGRES_USER: titanbot
      POSTGRES_PASSWORD: titanbot
      POSTGRES_SSL: "false"
      SCHEMA_VERSION: "1"
      SCHEMA_VERSION_LABEL: "baseline-v1"
 
    steps:
      - name: Checkout
        uses: actions/checkout@v4
 
      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: 20
          cache: npm
 
      - name: Install dependencies
        run: npm ci
 
      - name: Apply migrations
        run: npm run migrate
 
      - name: Validate migration version
        run: npm run migrate:check
 

What changed

What Latchkey heals here

This workflow has steps that commonly fail on transient issues (network, registries, flaky browsers). On Latchkey managed runners they are detected, retried, and self-healed instead of failing your build:

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