Skip to content

Commit db772be

Browse files
chore(ci): add CI_PROVIDER toggle between Blacksmith and GitHub-hosted runners
1 parent 58c87b2 commit db772be

9 files changed

Lines changed: 164 additions & 57 deletions

File tree

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Cache Mount
2+
description: Mount a build cache directory using Blacksmith sticky disks, or the GitHub Actions cache when running on GitHub-hosted runners.
3+
4+
inputs:
5+
provider:
6+
description: Set to 'github' to use actions/cache. Any other value (including unset) uses Blacksmith sticky disks.
7+
required: false
8+
default: ''
9+
key:
10+
description: Cache key. Shared by both backends, so callers keep one key regardless of provider.
11+
required: true
12+
path:
13+
description: Filesystem path the cache is mounted at.
14+
required: true
15+
16+
runs:
17+
using: composite
18+
steps:
19+
- name: Mount sticky disk
20+
if: inputs.provider != 'github'
21+
uses: useblacksmith/stickydisk@4c034ba57b706cf0e3b4b0ce098c2a3b1071580c # v1
22+
with:
23+
key: ${{ inputs.key }}
24+
path: ${{ inputs.path }}
25+
26+
# Sticky disks always re-commit the mounted path, so the cache rolls forward
27+
# every run. actions/cache skips its save step on an exact key hit, which
28+
# would freeze the cache at whatever the first run wrote — the run-scoped
29+
# suffix plus a prefix restore-key reproduces the rolling behaviour.
30+
- name: Restore and save cache
31+
if: inputs.provider == 'github'
32+
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
33+
with:
34+
key: ${{ inputs.key }}-${{ github.run_id }}
35+
restore-keys: ${{ inputs.key }}-
36+
path: ${{ inputs.path }}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Docker Build and Push
2+
description: Set up a buildx builder and build/push an image, using Blacksmith's builder or the upstream Docker actions on GitHub-hosted runners.
3+
4+
inputs:
5+
provider:
6+
description: Set to 'github' to use the upstream docker/* actions. Any other value (including unset) uses Blacksmith's builder.
7+
required: false
8+
default: ''
9+
context:
10+
description: Build context.
11+
required: false
12+
default: .
13+
file:
14+
description: Path to the Dockerfile.
15+
required: true
16+
platforms:
17+
description: Target platforms, e.g. linux/amd64.
18+
required: true
19+
tags:
20+
description: Comma-separated list of tags to push.
21+
required: true
22+
23+
# Registry logins must already have run in the calling job — both backends read
24+
# the same ~/.docker/config.json. provenance/sbom stay off everywhere: the
25+
# attestation manifests they add break `imagetools create` retagging in the
26+
# promote-images and create-ghcr-manifests jobs.
27+
runs:
28+
using: composite
29+
steps:
30+
- name: Set up Blacksmith builder
31+
if: inputs.provider != 'github'
32+
uses: useblacksmith/setup-docker-builder@ab5c1da94f53f5cd75c1038092aa276dddfccbba # v1
33+
34+
- name: Build and push (Blacksmith)
35+
if: inputs.provider != 'github'
36+
uses: useblacksmith/build-push-action@fb9e3e6a9299c78462bfadd0d93352c316adc9b8 # v2
37+
with:
38+
context: ${{ inputs.context }}
39+
file: ${{ inputs.file }}
40+
platforms: ${{ inputs.platforms }}
41+
push: true
42+
tags: ${{ inputs.tags }}
43+
provenance: false
44+
sbom: false
45+
46+
- name: Set up Docker Buildx
47+
if: inputs.provider == 'github'
48+
uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4
49+
50+
# No layer cache here. Blacksmith caches layers on the builder itself;
51+
# the GitHub equivalent (cache-to: type=gha) shares the same 10 GB repo
52+
# cache quota as the bun/node_modules/turbo mounts, and four images of
53+
# layers would evict them. Fallback builds are cold by design.
54+
- name: Build and push (GitHub)
55+
if: inputs.provider == 'github'
56+
uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7
57+
with:
58+
context: ${{ inputs.context }}
59+
file: ${{ inputs.file }}
60+
platforms: ${{ inputs.platforms }}
61+
push: true
62+
tags: ${{ inputs.tags }}
63+
provenance: false
64+
sbom: false

.github/workflows/ci.yml

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
name: CI
22

3+
# Runner provider toggle. Every job here and in the reusable workflows reads the
4+
# CI_PROVIDER repository variable:
5+
#
6+
# gh variable set CI_PROVIDER --body github # fall back to GitHub-hosted
7+
# gh variable delete CI_PROVIDER # back to Blacksmith (default)
8+
#
9+
# It is a repo variable rather than a committed value on purpose: during a
10+
# Blacksmith outage there is no working CI to merge a switchover commit through,
11+
# and the variable takes effect on the next run with nothing to land.
12+
#
13+
# GitHub mode is a break-glass fallback, not a peer. Public-repo ubuntu-latest is
14+
# 4 vCPU with no free 8-core tier, the 10 GB repo cache quota will thrash across
15+
# the bun/node_modules/turbo mounts, and image builds start from cold layers — so
16+
# expect slower runs, not different results. Blacksmith-only actions are reached
17+
# exclusively through .github/actions/cache-mount and .github/actions/docker-build,
18+
# which branch internally; a bare useblacksmith/* step added anywhere else will
19+
# hard-fail in GitHub mode rather than silently degrade.
20+
321
on:
422
push:
523
branches: [main, staging, dev]
@@ -28,7 +46,7 @@ jobs:
2846
# Detect if this is a version release commit (e.g., "v0.5.24: ...")
2947
detect-version:
3048
name: Detect Version
31-
runs-on: blacksmith-4vcpu-ubuntu-2404
49+
runs-on: ${{ vars.CI_PROVIDER == 'github' && 'ubuntu-latest' || 'blacksmith-4vcpu-ubuntu-2404' }}
3250
timeout-minutes: 5
3351
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/staging' || github.ref == 'refs/heads/dev')
3452
outputs:
@@ -81,7 +99,7 @@ jobs:
8199
name: Build Dev ECR
82100
needs: [detect-version, migrate-dev]
83101
if: github.event_name == 'push' && github.ref == 'refs/heads/dev'
84-
runs-on: blacksmith-8vcpu-ubuntu-2404
102+
runs-on: ${{ vars.CI_PROVIDER == 'github' && 'ubuntu-latest' || 'blacksmith-8vcpu-ubuntu-2404' }}
85103
timeout-minutes: 30
86104
permissions:
87105
contents: read
@@ -118,25 +136,19 @@ jobs:
118136
username: ${{ secrets.DOCKERHUB_USERNAME }}
119137
password: ${{ secrets.DOCKERHUB_TOKEN }}
120138

121-
- name: Set up Docker Buildx
122-
uses: useblacksmith/setup-docker-builder@ab5c1da94f53f5cd75c1038092aa276dddfccbba # v1
123-
124139
- name: Resolve ECR repo name
125140
id: ecr-repo
126141
run: echo "name=$ECR_REPO" >> $GITHUB_OUTPUT
127142
env:
128143
ECR_REPO: ${{ matrix.ecr_repo_secret == 'ECR_APP' && secrets.ECR_APP || matrix.ecr_repo_secret == 'ECR_MIGRATIONS' && secrets.ECR_MIGRATIONS || matrix.ecr_repo_secret == 'ECR_REALTIME' && secrets.ECR_REALTIME || matrix.ecr_repo_secret == 'ECR_PII' && secrets.ECR_PII || '' }}
129144

130145
- name: Build and push
131-
uses: useblacksmith/build-push-action@fb9e3e6a9299c78462bfadd0d93352c316adc9b8 # v2
146+
uses: ./.github/actions/docker-build
132147
with:
133-
context: .
148+
provider: ${{ vars.CI_PROVIDER }}
134149
file: ${{ matrix.dockerfile }}
135150
platforms: linux/amd64
136-
push: true
137151
tags: ${{ steps.login-ecr.outputs.registry }}/${{ steps.ecr-repo.outputs.name }}:dev
138-
provenance: false
139-
sbom: false
140152

141153
# Dev: deploy Trigger.dev background tasks to the preview "dev-sim" branch.
142154
# Gated after migrate-dev for the same reason as build-dev — the new task
@@ -145,7 +157,7 @@ jobs:
145157
name: Deploy Trigger.dev (Dev)
146158
needs: [migrate-dev]
147159
if: github.event_name == 'push' && github.ref == 'refs/heads/dev'
148-
runs-on: blacksmith-4vcpu-ubuntu-2404
160+
runs-on: ${{ vars.CI_PROVIDER == 'github' && 'ubuntu-latest' || 'blacksmith-4vcpu-ubuntu-2404' }}
149161
timeout-minutes: 15
150162
steps:
151163
- name: Checkout code
@@ -192,7 +204,7 @@ jobs:
192204
if: >-
193205
github.event_name == 'push' &&
194206
(github.ref == 'refs/heads/main' || github.ref == 'refs/heads/staging')
195-
runs-on: blacksmith-8vcpu-ubuntu-2404
207+
runs-on: ${{ vars.CI_PROVIDER == 'github' && 'ubuntu-latest' || 'blacksmith-8vcpu-ubuntu-2404' }}
196208
timeout-minutes: 30
197209
permissions:
198210
contents: read
@@ -242,9 +254,6 @@ jobs:
242254
username: ${{ github.repository_owner }}
243255
password: ${{ secrets.GITHUB_TOKEN }}
244256

245-
- name: Set up Docker Buildx
246-
uses: useblacksmith/setup-docker-builder@ab5c1da94f53f5cd75c1038092aa276dddfccbba # v1
247-
248257
- name: Resolve ECR repo name
249258
id: ecr-repo
250259
run: echo "name=$ECR_REPO" >> $GITHUB_OUTPUT
@@ -270,15 +279,12 @@ jobs:
270279
echo "tags=${TAGS}" >> $GITHUB_OUTPUT
271280
272281
- name: Build and push images
273-
uses: useblacksmith/build-push-action@fb9e3e6a9299c78462bfadd0d93352c316adc9b8 # v2
282+
uses: ./.github/actions/docker-build
274283
with:
275-
context: .
284+
provider: ${{ vars.CI_PROVIDER }}
276285
file: ${{ matrix.dockerfile }}
277286
platforms: linux/amd64
278-
push: true
279287
tags: ${{ steps.meta.outputs.tags }}
280-
provenance: false
281-
sbom: false
282288

283289
# Promote the sha-tagged ECR images to the deploy tags once tests and
284290
# migrations pass. Pushing the ECR latest/staging tag is what triggers
@@ -292,7 +298,7 @@ jobs:
292298
if: >-
293299
github.event_name == 'push' &&
294300
(github.ref == 'refs/heads/main' || github.ref == 'refs/heads/staging')
295-
runs-on: blacksmith-2vcpu-ubuntu-2404
301+
runs-on: ${{ vars.CI_PROVIDER == 'github' && 'ubuntu-latest' || 'blacksmith-2vcpu-ubuntu-2404' }}
296302
timeout-minutes: 10
297303
permissions:
298304
contents: read
@@ -362,7 +368,7 @@ jobs:
362368
# never moves a documented tag.
363369
build-ghcr-arm64:
364370
name: Build ARM64 (GHCR Only)
365-
runs-on: blacksmith-8vcpu-ubuntu-2404-arm
371+
runs-on: ${{ vars.CI_PROVIDER == 'github' && 'ubuntu-24.04-arm' || 'blacksmith-8vcpu-ubuntu-2404-arm' }}
366372
timeout-minutes: 30
367373
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
368374
permissions:
@@ -392,26 +398,20 @@ jobs:
392398
username: ${{ github.repository_owner }}
393399
password: ${{ secrets.GITHUB_TOKEN }}
394400

395-
- name: Set up Docker Buildx
396-
uses: useblacksmith/setup-docker-builder@ab5c1da94f53f5cd75c1038092aa276dddfccbba # v1
397-
398401
- name: Build and push ARM64 to GHCR
399-
uses: useblacksmith/build-push-action@fb9e3e6a9299c78462bfadd0d93352c316adc9b8 # v2
402+
uses: ./.github/actions/docker-build
400403
with:
401-
context: .
404+
provider: ${{ vars.CI_PROVIDER }}
402405
file: ${{ matrix.dockerfile }}
403406
platforms: linux/arm64
404-
push: true
405407
tags: ${{ matrix.image }}:${{ github.sha }}-arm64
406-
provenance: false
407-
sbom: false
408408

409409
# Publish all mutable GHCR tags (latest, latest-amd64/arm64, version tags)
410410
# and the multi-arch manifests from the immutable sha tags — only on main,
411411
# after the deploy gate (promote-images) and the ARM64 build both pass.
412412
create-ghcr-manifests:
413413
name: Create GHCR Manifests
414-
runs-on: blacksmith-2vcpu-ubuntu-2404
414+
runs-on: ${{ vars.CI_PROVIDER == 'github' && 'ubuntu-latest' || 'blacksmith-2vcpu-ubuntu-2404' }}
415415
timeout-minutes: 10
416416
needs: [promote-images, build-ghcr-arm64, detect-version]
417417
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
@@ -477,7 +477,7 @@ jobs:
477477
# Check if docs changed
478478
check-docs-changes:
479479
name: Check Docs Changes
480-
runs-on: blacksmith-4vcpu-ubuntu-2404
480+
runs-on: ${{ vars.CI_PROVIDER == 'github' && 'ubuntu-latest' || 'blacksmith-4vcpu-ubuntu-2404' }}
481481
timeout-minutes: 5
482482
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
483483
outputs:
@@ -506,7 +506,7 @@ jobs:
506506
# Create GitHub Release (only for version commits on main, after all builds complete)
507507
create-release:
508508
name: Create GitHub Release
509-
runs-on: blacksmith-4vcpu-ubuntu-2404
509+
runs-on: ${{ vars.CI_PROVIDER == 'github' && 'ubuntu-latest' || 'blacksmith-4vcpu-ubuntu-2404' }}
510510
timeout-minutes: 10
511511
needs: [create-ghcr-manifests, detect-version]
512512
if: needs.detect-version.outputs.is_release == 'true'

.github/workflows/docs-embeddings.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ permissions:
1010
jobs:
1111
process-docs-embeddings:
1212
name: Process Documentation Embeddings
13-
runs-on: blacksmith-8vcpu-ubuntu-2404
13+
runs-on: ${{ vars.CI_PROVIDER == 'github' && 'ubuntu-latest' || 'blacksmith-8vcpu-ubuntu-2404' }}
1414
timeout-minutes: 30
1515
if: github.ref == 'refs/heads/main'
1616

.github/workflows/migrations.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ permissions:
2424
jobs:
2525
migrate:
2626
name: Apply Database Migrations
27-
runs-on: blacksmith-4vcpu-ubuntu-2404
27+
runs-on: ${{ vars.CI_PROVIDER == 'github' && 'ubuntu-latest' || 'blacksmith-4vcpu-ubuntu-2404' }}
2828
timeout-minutes: 45
2929

3030
steps:

.github/workflows/publish-cli.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ permissions:
1111

1212
jobs:
1313
publish-npm:
14-
runs-on: blacksmith-4vcpu-ubuntu-2404
14+
runs-on: ${{ vars.CI_PROVIDER == 'github' && 'ubuntu-latest' || 'blacksmith-4vcpu-ubuntu-2404' }}
1515
timeout-minutes: 15
1616
steps:
1717
- name: Checkout repository

.github/workflows/publish-python-sdk.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ permissions:
1111

1212
jobs:
1313
publish-pypi:
14-
runs-on: blacksmith-4vcpu-ubuntu-2404
14+
runs-on: ${{ vars.CI_PROVIDER == 'github' && 'ubuntu-latest' || 'blacksmith-4vcpu-ubuntu-2404' }}
1515
timeout-minutes: 15
1616
steps:
1717
- name: Checkout repository

.github/workflows/publish-ts-sdk.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ permissions:
1111

1212
jobs:
1313
publish-npm:
14-
runs-on: blacksmith-4vcpu-ubuntu-2404
14+
runs-on: ${{ vars.CI_PROVIDER == 'github' && 'ubuntu-latest' || 'blacksmith-4vcpu-ubuntu-2404' }}
1515
timeout-minutes: 15
1616
steps:
1717
- name: Checkout repository

0 commit comments

Comments
 (0)