Skip to content
Latchkey

update-sqlite workflow (WiseLibs/better-sqlite3)

The update-sqlite workflow from WiseLibs/better-sqlite3, explained and optimized by Latchkey.

C

CI health: C - fair

Point runs-on at Latchkey and get caching, job timeouts, SHA-pinned actions, self-healing for flaky steps, and up to 58% lower cost, applied automatically.

Grade your own workflow free or run it on Latchkey →
Source: WiseLibs/better-sqlite3.github/workflows/update-sqlite.ymlLicense MITView source

What it does

This is the update-sqlite workflow from the WiseLibs/better-sqlite3 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: update-sqlite

on:
  workflow_dispatch:
    inputs:
      year:
        description: SQLite release year
        required: true
      version:
        description: SQLite version (encoded)
        required: true

jobs:
  download-and-update:
    name: Download and update SQLite
    runs-on: ubuntu-latest
    env:
      ENV_YEAR: ${{ github.event.inputs.year }}
      ENV_VERSION: ${{ github.event.inputs.version }}
    steps:
      - uses: actions/checkout@v6
        with:
          token: ${{ secrets.PAT }}
          fetch-depth: 0
      - uses: actions/setup-node@v6
        with:
          node-version: 20
      - name: Create new update branch
        run: git checkout -b sqlite-update-${{ env.ENV_VERSION }}
      - name: Update download script
        run: |
          sed -Ei "s/YEAR=\"[0-9]+\"/YEAR=\"${{ env.ENV_YEAR }}\"/g" ./deps/download.sh
          sed -Ei "s/VERSION=\"[0-9]+\"/VERSION=\"${{ env.ENV_VERSION }}\"/g" ./deps/download.sh
          echo "ENV_TRUE_VERSION=$((10#${ENV_VERSION:0:1})).$((10#${ENV_VERSION:1:2})).$((10#${ENV_VERSION:3:2}))" >> $GITHUB_ENV
      - name: Download, compile and package SQLite
        run: npm run download
      - name: Push update branch
        uses: stefanzweifel/git-auto-commit-action@v7
        with:
          commit_message: Update SQLite to version ${{ env.ENV_TRUE_VERSION }}
          branch: sqlite-update-${{ env.ENV_VERSION }}
      - name: Create new PR
        uses: repo-sync/pull-request@v2
        with:
          github_token: ${{ secrets.PAT }}
          source_branch: sqlite-update-${{ env.ENV_VERSION }}
          pr_title: Update SQLite to version ${{ env.ENV_TRUE_VERSION }}
          pr_body: This is an automated pull request, updating SQLite to version `${{ env.ENV_TRUE_VERSION }}`.

The same workflow, on Latchkey

Estimated ~20% faster on cache hits, plus fewer wasted runs and a safer supply chain. Added and changed lines are highlighted.

name: update-sqlite
 
on:
  workflow_dispatch:
    inputs:
      year:
        description: SQLite release year
        required: true
      version:
        description: SQLite version (encoded)
        required: true
 
jobs:
  download-and-update:
    timeout-minutes: 30
    name: Download and update SQLite
    runs-on: latchkey-small
    env:
      ENV_YEAR: ${{ github.event.inputs.year }}
      ENV_VERSION: ${{ github.event.inputs.version }}
    steps:
      - uses: actions/checkout@v6
        with:
          token: ${{ secrets.PAT }}
          fetch-depth: 0
      - uses: actions/setup-node@v6
        with:
          cache: 'npm'
          node-version: 20
      - name: Create new update branch
        run: git checkout -b sqlite-update-${{ env.ENV_VERSION }}
      - name: Update download script
        run: |
          sed -Ei "s/YEAR=\"[0-9]+\"/YEAR=\"${{ env.ENV_YEAR }}\"/g" ./deps/download.sh
          sed -Ei "s/VERSION=\"[0-9]+\"/VERSION=\"${{ env.ENV_VERSION }}\"/g" ./deps/download.sh
          echo "ENV_TRUE_VERSION=$((10#${ENV_VERSION:0:1})).$((10#${ENV_VERSION:1:2})).$((10#${ENV_VERSION:3:2}))" >> $GITHUB_ENV
      - name: Download, compile and package SQLite
        run: npm run download
      - name: Push update branch
        uses: stefanzweifel/git-auto-commit-action@v7
        with:
          commit_message: Update SQLite to version ${{ env.ENV_TRUE_VERSION }}
          branch: sqlite-update-${{ env.ENV_VERSION }}
      - name: Create new PR
        uses: repo-sync/pull-request@v2
        with:
          github_token: ${{ secrets.PAT }}
          source_branch: sqlite-update-${{ env.ENV_VERSION }}
          pr_title: Update SQLite to version ${{ env.ENV_TRUE_VERSION }}
          pr_body: This is an automated pull request, updating SQLite to version `${{ env.ENV_TRUE_VERSION }}`.
 

What changed

2 third-party actions are referenced by a movable tag. Pin them to the commit SHA (Latchkey resolves and applies this automatically) so a repointed tag cannot change what runs.

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