-
Notifications
You must be signed in to change notification settings - Fork 3.7k
chore(ci): add CI_PROVIDER toggle between Blacksmith and GitHub-hosted runners #5808
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| name: Cache Mount | ||
| description: Mount a build cache directory using Blacksmith sticky disks, or the GitHub Actions cache when running on GitHub-hosted runners. | ||
|
|
||
| inputs: | ||
| provider: | ||
| description: Empty or 'blacksmith' selects sticky disks. Any other value selects actions/cache. Must stay byte-identical to the runs-on predicate in the calling workflow. | ||
| required: false | ||
| default: '' | ||
| key: | ||
| description: Cache key. Shared by both backends, so callers keep one key regardless of provider. | ||
| required: true | ||
| path: | ||
| description: Filesystem path the cache is mounted at. | ||
| required: true | ||
|
|
||
| # The two conditions are exact complements of the runs-on expression the caller | ||
| # uses. They must be inverted together: a job placed on ubuntu-latest that then | ||
| # took the sticky-disk branch would hard-fail, since stickydisk hot-mounts an | ||
| # ext4 volume from Blacksmith's storage agents and cannot run anywhere else. | ||
| runs: | ||
| using: composite | ||
| steps: | ||
| - name: Mount sticky disk | ||
| if: inputs.provider == '' || inputs.provider == 'blacksmith' | ||
| uses: useblacksmith/stickydisk@4c034ba57b706cf0e3b4b0ce098c2a3b1071580c # v1 | ||
| with: | ||
| key: ${{ inputs.key }} | ||
| path: ${{ inputs.path }} | ||
|
|
||
| # Sticky disks always re-commit the mounted path, so the cache rolls forward | ||
| # every run. actions/cache skips its save step on an exact key hit, which | ||
| # would freeze the cache at whatever the first run wrote — the run-scoped | ||
| # suffix plus a prefix restore-key reproduces the rolling behaviour. | ||
| - name: Restore and save cache | ||
| if: inputs.provider != '' && inputs.provider != 'blacksmith' | ||
| uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5 | ||
| with: | ||
| key: ${{ inputs.key }}-${{ github.run_id }} | ||
| restore-keys: ${{ inputs.key }}- | ||
| path: ${{ inputs.path }} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| name: Docker Build and Push | ||
| description: Set up a buildx builder and build/push an image, using Blacksmith's builder or the upstream Docker actions on GitHub-hosted runners. | ||
|
|
||
| inputs: | ||
| provider: | ||
| description: Empty or 'blacksmith' selects Blacksmith's builder. Any other value selects the upstream docker/* actions. Must stay byte-identical to the runs-on predicate in the calling workflow. | ||
| required: false | ||
| default: '' | ||
| context: | ||
| description: Build context. | ||
| required: false | ||
| default: . | ||
| file: | ||
| description: Path to the Dockerfile. | ||
| required: true | ||
| platforms: | ||
| description: Target platforms, e.g. linux/amd64. | ||
| required: true | ||
| tags: | ||
| description: Comma-separated list of tags to push. | ||
| required: true | ||
|
|
||
| # Registry logins must already have run in the calling job — both backends read | ||
| # the same ~/.docker/config.json. provenance/sbom stay off everywhere: the | ||
| # attestation manifests they add break `imagetools create` retagging in the | ||
| # promote-images and create-ghcr-manifests jobs. | ||
| runs: | ||
| using: composite | ||
| steps: | ||
| - name: Set up Blacksmith builder | ||
| if: inputs.provider == '' || inputs.provider == 'blacksmith' | ||
| uses: useblacksmith/setup-docker-builder@ab5c1da94f53f5cd75c1038092aa276dddfccbba # v1 | ||
|
|
||
| - name: Build and push (Blacksmith) | ||
| if: inputs.provider == '' || inputs.provider == 'blacksmith' | ||
| uses: useblacksmith/build-push-action@fb9e3e6a9299c78462bfadd0d93352c316adc9b8 # v2 | ||
| with: | ||
| context: ${{ inputs.context }} | ||
| file: ${{ inputs.file }} | ||
| platforms: ${{ inputs.platforms }} | ||
| push: true | ||
| tags: ${{ inputs.tags }} | ||
| provenance: false | ||
| sbom: false | ||
|
|
||
| - name: Set up Docker Buildx | ||
| if: inputs.provider != '' && inputs.provider != 'blacksmith' | ||
| uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4 | ||
|
|
||
| # No layer cache here. Blacksmith caches layers on the builder itself; | ||
| # the GitHub equivalent (cache-to: type=gha) shares the same 10 GB repo | ||
| # cache quota as the bun/node_modules/turbo mounts, and four images of | ||
| # layers would evict them. Fallback builds are cold by design. | ||
| - name: Build and push (GitHub) | ||
| if: inputs.provider != '' && inputs.provider != 'blacksmith' | ||
| uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7 | ||
| with: | ||
| context: ${{ inputs.context }} | ||
| file: ${{ inputs.file }} | ||
| platforms: ${{ inputs.platforms }} | ||
| push: true | ||
| tags: ${{ inputs.tags }} | ||
| provenance: false | ||
| sbom: false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.