Skip to content
Latchkey

Restore Drill workflow (codebymitch/TitanBot)

The Restore Drill workflow from codebymitch/TitanBot, explained and optimized by Latchkey.

A

CI health: A - excellent

Point runs-on at Latchkey and get 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/restore-drill.ymlLicense MITView source

What it does

This is the Restore Drill 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: Restore Drill

on:
  schedule:
    - cron: '0 4 * * 1'
  workflow_dispatch:

jobs:
  restore-drill:
    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"
      BACKUP_RETENTION_DAYS: "7"

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

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

      - name: Install PostgreSQL client tools
        run: sudo apt-get update ; sudo apt-get install -y postgresql-client

      - name: Install dependencies
        run: npm ci

      - name: Apply migrations
        run: npm run migrate

      - name: Run restore drill
        run: npm run backup:drill

The same workflow, on Latchkey

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

name: Restore Drill
 
on:
  schedule:
    - cron: '0 4 * * 1'
  workflow_dispatch:
 
jobs:
  restore-drill:
    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"
      BACKUP_RETENTION_DAYS: "7"
 
    steps:
      - name: Checkout
        uses: actions/checkout@v4
 
      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: 20
          cache: npm
 
      - name: Install PostgreSQL client tools
        run: sudo apt-get update ; sudo apt-get install -y postgresql-client
 
      - name: Install dependencies
        run: npm ci
 
      - name: Apply migrations
        run: npm run migrate
 
      - name: Run restore drill
        run: npm run backup:drill
 

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