Skip to content

Commit

Permalink
ci: switch to inline cache
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed Nov 9, 2023
1 parent acccaf8 commit b7d41b0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 17 deletions.
8 changes: 2 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,6 @@ jobs:
# The .ts scripts depend upon this
- run: npm install --global tsx

- name: Export vars of Actions Runtime for caching
uses: crazy-max/ghaction-github-runtime@v3

- name: build use images
run: ./buildUseImages.ts

Expand All @@ -83,9 +80,8 @@ jobs:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# use GitHub Actions Cache https://github.com/moby/buildkit#github-actions-cache-experimental
cache-from: type=gha
cache-to: type=gha,mode=max
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:main
cache-to: type=inline

- name: notify on failure
if: failure() && github.event_name != 'pull_request'
Expand Down
12 changes: 1 addition & 11 deletions buildTestImages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,14 @@ const proposals = match
? allProposals.filter(p => p.proposalName.includes(match))
: allProposals;

function buildOptsFor(name: string) {
// use GitHub Actions Cache if enabled https://docs.docker.com/build/cache/backends/gha/
if (process.env.ACTIONS_RUNTIME_TOKEN) {
const refName = process.env.GITHUB_REF_NAME;
return `--cache-from type=gha,scope=${refName}-${name} --cache-to type=gha,mode=max,scope=${refName}-${name}`;
}
return '';
}

for (const proposal of proposals) {
if (!dry) {
console.log(`\nBuilding test image for proposal ${proposal.proposalName}`);
}
const { name, target } = imageNameForProposal(proposal, 'test');
const opts = buildOptsFor(name);
// 'load' to ensure the images are output to the Docker client. Seems to be necessary
// for the CI docker/build-push-action to re-use the cached stages.
const cmd = `docker buildx build ${opts} --load --tag ${name} --target ${target} .`;
const cmd = `docker buildx build --load --tag ${name} --target ${target} .`;
console.log(cmd);
if (!dry) {
execSync(cmd, { stdio: 'inherit' });
Expand Down

0 comments on commit b7d41b0

Please sign in to comment.