Skip to content

Commit

Permalink
ci: use GitHub Actions Cache
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed Nov 6, 2023
1 parent bce7f5d commit aa32d92
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
12 changes: 9 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,12 @@ jobs:
# The .ts scripts depend upon this
- run: yarn global add tsx

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

- name: build test images
run: |
docker info
./buildTestImages.ts
run: ./buildTestImages.ts --buildOpts="--cache-from type=gha --cache-to type=gha,mode=max"

- name: run test images
run: ./runTestImages.ts

Expand All @@ -77,6 +79,10 @@ 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

- name: notify on failure
if: failure() && github.event_name != 'pull_request'
uses: ./.github/actions/notify-status
Expand Down
5 changes: 3 additions & 2 deletions buildTestImages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ import { refreshDockerfile } from './makeDockerfile';
refreshDockerfile();

const options = {
buildOpts: { type: 'string' },
match: { short: 'm', type: 'string' },
dry: { type: 'boolean' },
} as const;
const { values } = parseArgs({ options });

const { match, dry } = values;
const { buildOpts, match, dry } = values;

const allProposals = readProposals();

Expand All @@ -28,7 +29,7 @@ for (const proposal of proposals) {
const { name, target } = imageNameForProposalTest(proposal);
// '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 --load --tag ${name} --target ${target} .`;
const cmd = `docker buildx build ${buildOpts} --load --tag ${name} --target ${target} .`;
console.log(cmd);
if (!dry) {
execSync(cmd, { stdio: 'inherit' });
Expand Down

0 comments on commit aa32d92

Please sign in to comment.