pre-release workflow (ChatGPTBox-dev/chatGPTBox)
The pre-release workflow from ChatGPTBox-dev/chatGPTBox, explained and optimized by Latchkey.
CI health: B - good
Point runs-on at Latchkey and get job timeouts, SHA-pinned actions, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the pre-release workflow from the ChatGPTBox-dev/chatGPTBox 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: pre-release
on:
workflow_dispatch:
# push:
# branches:
# - master
# paths:
# - "src/**"
# - "!src/**/*.json"
# - "build.mjs"
# tags-ignore:
# - "v*"
permissions:
id-token: "write"
contents: "write"
jobs:
build_and_release:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v6
with:
node-version: 22
cache: 'npm'
cache-dependency-path: '**/package-lock.json'
- name: Detect Node version
run: echo "NODE_VERSION=$(node -p 'process.versions.node')" >> $GITHUB_ENV
- run: npm ci
- name: Cache Webpack filesystem cache
uses: actions/cache@v6
with:
path: |
.cache/webpack
node_modules/.cache/webpack
key: ${{ runner.os }}-node${{ env.NODE_VERSION }}-webpack-${{ hashFiles('**/package-lock.json', 'build.mjs') }}
restore-keys: |
${{ runner.os }}-node${{ env.NODE_VERSION }}-webpack-
- run: npm run build
- uses: josStorer/get-current-time@v2
id: current-time
with:
format: YYYY_MMDD_HHmm
- uses: actions/upload-artifact@v7
with:
name: Chromium_Build_${{ steps.current-time.outputs.formattedTime }}
path: build/chromium/*
- uses: actions/upload-artifact@v7
with:
name: Firefox_Build_${{ steps.current-time.outputs.formattedTime }}
path: build/firefox/*
- uses: actions/upload-artifact@v7
with:
name: Chromium_Build_WithoutKatex_${{ steps.current-time.outputs.formattedTime }}
path: build/chromium-without-katex-and-tiktoken/*
- uses: actions/upload-artifact@v7
with:
name: Firefox_Build_WithoutKatex_${{ steps.current-time.outputs.formattedTime }}
path: build/firefox-without-katex-and-tiktoken/*
- uses: marvinpinto/action-automatic-releases@v1.2.1
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "latest"
prerelease: true
title: "Development Build"
files: |
build/chromium.zip
build/firefox.zip
build/chromium-without-katex-and-tiktoken.zip
build/firefox-without-katex-and-tiktoken.zip
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: pre-release on: workflow_dispatch: # push: # branches: # - master # paths: # - "src/**" # - "!src/**/*.json" # - "build.mjs" # tags-ignore: # - "v*" permissions: id-token: "write" contents: "write" jobs: build_and_release: timeout-minutes: 30 runs-on: latchkey-small steps: - uses: actions/checkout@v7 - uses: actions/setup-node@v6 with: node-version: 22 cache: 'npm' cache-dependency-path: '**/package-lock.json' - name: Detect Node version run: echo "NODE_VERSION=$(node -p 'process.versions.node')" >> $GITHUB_ENV - run: npm ci - name: Cache Webpack filesystem cache uses: actions/cache@v6 with: path: | .cache/webpack node_modules/.cache/webpack key: ${{ runner.os }}-node${{ env.NODE_VERSION }}-webpack-${{ hashFiles('**/package-lock.json', 'build.mjs') }} restore-keys: | ${{ runner.os }}-node${{ env.NODE_VERSION }}-webpack- - run: npm run build - uses: josStorer/get-current-time@v2 id: current-time with: format: YYYY_MMDD_HHmm - uses: actions/upload-artifact@v7 with: name: Chromium_Build_${{ steps.current-time.outputs.formattedTime }} path: build/chromium/* - uses: actions/upload-artifact@v7 with: name: Firefox_Build_${{ steps.current-time.outputs.formattedTime }} path: build/firefox/* - uses: actions/upload-artifact@v7 with: name: Chromium_Build_WithoutKatex_${{ steps.current-time.outputs.formattedTime }} path: build/chromium-without-katex-and-tiktoken/* - uses: actions/upload-artifact@v7 with: name: Firefox_Build_WithoutKatex_${{ steps.current-time.outputs.formattedTime }} path: build/firefox-without-katex-and-tiktoken/* - uses: marvinpinto/action-automatic-releases@v1.2.1 with: repo_token: "${{ secrets.GITHUB_TOKEN }}" automatic_release_tag: "latest" prerelease: true title: "Development Build" files: | build/chromium.zip build/firefox.zip build/chromium-without-katex-and-tiktoken.zip build/firefox-without-katex-and-tiktoken.zip
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. - Add a job timeout so a hung step cannot burn hours of runner time.
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.
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.