Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

only cache on main write

Thiago Araujo da Silva42cbf208dd14
diff --git a/.github/actions/generate-openapi-spec/action.yml b/.github/actions/generate-openapi-spec/action.yml
index d1fa76c1e4..6d450d99a6 100644
--- a/.github/actions/generate-openapi-spec/action.yml
+++ b/.github/actions/generate-openapi-spec/action.yml
@@ -17,12 +17,18 @@ inputs:
description: "Name for the API container."
required: false
default: "infisical-api"
+ write-layer-cache:
+ description: >-
+ Whether to export the Docker layer cache. Leave this off outside the default branch:
+ a cache a PR writes is readable only by that PR, so it does nothing for anyone else
+ while still consuming the repository's cache quota and evicting the entries on main
+ that every PR reads from.
+ required: false
+ default: "false"
runs:
using: "composite"
steps:
- - uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
-
- name: Build the API image
uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6.19.2
with:
@@ -30,7 +36,7 @@ runs:
load: true
tags: ${{ inputs.container-name }}
cache-from: type=gha,scope=openapi-spec
- cache-to: type=gha,mode=max,scope=openapi-spec
+ cache-to: ${{ inputs.write-layer-cache == 'true' && 'type=gha,mode=max,scope=openapi-spec' || '' }}
- name: Create the database
shell: bash
diff --git a/.github/workflows/check-api-for-breaking-changes.yml b/.github/workflows/check-api-for-breaking-changes.yml
index 341e108581..bd935b8273 100644
--- a/.github/workflows/check-api-for-breaking-changes.yml
+++ b/.github/workflows/check-api-for-breaking-changes.yml
@@ -48,6 +48,9 @@ jobs:
with:
version: "2.14.2"
+ - name: Set up buildx
+ uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
+
- name: Resolve baseline
id: baseline
run: |
diff --git a/.github/workflows/publish-openapi-spec.yml b/.github/workflows/publish-openapi-spec.yml
index f98aabbdec..cfb0be7c47 100644
--- a/.github/workflows/publish-openapi-spec.yml
+++ b/.github/workflows/publish-openapi-spec.yml
@@ -5,7 +5,8 @@ name: "Publish OpenAPI Spec"
#
# This job exists because of GitHub's cache scoping: a PR can read caches written on
# the default branch, but caches a PR writes are visible only to that PR. Baselines
-# therefore have to be produced by a run on main.
+# therefore have to be produced by a run on main. The Docker layer cache the spec
+# generator uses is scoped the same way, so this job is also the only writer of that.
#
# The cache path below MUST stay identical to the one the checker restores, because
# actions/cache folds the path into the cache version. A mismatched path misses even
@@ -48,6 +49,10 @@ jobs:
key: ${{ steps.key.outputs.key }}
lookup-only: true
+ - name: Set up buildx
+ if: steps.probe.outputs.cache-hit != 'true'
+ uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
+
- name: Start postgres and redis
if: steps.probe.outputs.cache-hit != 'true'
run: touch .env && docker compose -f docker-compose.dev.yml up -d db redis
@@ -57,6 +62,7 @@ jobs:
uses: ./.github/actions/generate-openapi-spec
with:
output: base-spec.json
+ write-layer-cache: "true"
- name: Publish spec
if: steps.probe.outputs.cache-hit != 'true'