Migration Version Check workflow (codebymitch/TitanBot)
The Migration Version Check workflow from codebymitch/TitanBot, explained and optimized by Latchkey.
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.
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
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
- Run on Latchkey managed runners with one line (
runs-on), which apply the fixes below automatically and self-heal transient failures. This example useslatchkey-small; pick the runner size that fits the job. - Cancel superseded runs when a branch or PR gets a newer push.
- Add a job timeout so a hung step cannot burn hours of runner time.
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:
- Dependency installs
This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.