Skip to content

Commit b9f7016

Browse files
internal: Implements build cache for API files
1 parent 07e20b8 commit b9f7016

File tree

147 files changed

+20894
-16922
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

147 files changed

+20894
-16922
lines changed

.github/workflows/ci.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@ jobs:
2525
- name: Install dependencies
2626
run: yarn install --immutable
2727

28+
- name: Cache OpenAPI documentation
29+
uses: actions/cache@v4
30+
with:
31+
path: .openapi-cache
32+
key: openapi-cache-${{ runner.os }}-${{ hashFiles('openapi/**/*.yaml') }}
33+
restore-keys: |
34+
openapi-cache-${{ runner.os }}-
35+
openapi-cache-
36+
2837
- name: Check for incorrect support email
2938
run: |
3039
echo "Checking for usage of [email protected]..."
@@ -37,4 +46,6 @@ jobs:
3746
fi
3847
3948
- name: Test build website
40-
run: yarn build
49+
run: |
50+
echo "Building website..."
51+
yarn build

.github/workflows/gh-pages.yml

Lines changed: 0 additions & 65 deletions
This file was deleted.
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
name: Sync OpenAPI Specs
2+
3+
on:
4+
schedule:
5+
- cron: '0 2 * * *' # Daily at 2 AM UTC
6+
workflow_dispatch:
7+
inputs:
8+
reason:
9+
description: 'Reason for manual sync (optional)'
10+
required: false
11+
default: 'Manual trigger'
12+
13+
permissions:
14+
contents: write
15+
pull-requests: write
16+
17+
jobs:
18+
sync-specs:
19+
runs-on: ubuntu-latest
20+
outputs:
21+
has_changes: ${{ steps.check-changes.outputs.has_changes }}
22+
23+
steps:
24+
- name: Checkout repository
25+
uses: actions/checkout@v4
26+
with:
27+
fetch-depth: 0
28+
token: ${{ secrets.GITHUB_TOKEN }}
29+
30+
- name: Download and process OpenAPI specs
31+
id: download-specs
32+
run: |
33+
echo "📥 Downloading and processing OpenAPI specs..."
34+
35+
# Create spec directories if they don't exist
36+
mkdir -p openapi/client openapi/indexing
37+
38+
# Download and capitalize client API spec
39+
echo "Downloading and capitalizing client API spec..."
40+
if yarn openapi:capitalize:client; then
41+
echo "✅ Client API spec downloaded and capitalized successfully"
42+
else
43+
echo "❌ Failed to download/capitalize client API spec"
44+
exit 1
45+
fi
46+
47+
# Download and capitalize indexing API spec
48+
echo "Downloading and capitalizing indexing API spec..."
49+
if node scripts/openapi-capitalize-language.mjs https://gleanwork.github.io/open-api/specs/final/indexing.yaml openapi/indexing/indexing-capitalized.yaml; then
50+
echo "✅ Indexing API spec downloaded and capitalized successfully"
51+
else
52+
echo "❌ Failed to download/capitalize indexing API spec"
53+
exit 1
54+
fi
55+
56+
echo "✅ All specs downloaded and processed successfully"
57+
58+
- name: Check for changes
59+
id: check-changes
60+
run: |
61+
if [[ -n $(git status --porcelain openapi/) ]]; then
62+
echo "has_changes=true" >> $GITHUB_OUTPUT
63+
echo "📝 Changes detected in OpenAPI specs"
64+
git diff --name-only openapi/
65+
else
66+
echo "has_changes=false" >> $GITHUB_OUTPUT
67+
echo "✅ No changes in OpenAPI specs"
68+
fi
69+
70+
- name: Create Pull Request with spec updates
71+
if: steps.check-changes.outputs.has_changes == 'true'
72+
id: create-pr
73+
uses: peter-evans/create-pull-request@v5
74+
with:
75+
token: ${{ secrets.GITHUB_TOKEN }}
76+
commit-message: |
77+
chore: sync latest OpenAPI specs
78+
79+
Automated sync of latest OpenAPI specifications from GitHub Pages.
80+
Specs updated: client_rest.yaml, indexing.yaml
81+
title: '🔄 Sync OpenAPI Specifications'
82+
body: |
83+
## 🔄 Automated OpenAPI Specifications Sync
84+
85+
This PR contains the latest OpenAPI specifications synced from GitHub Pages.
86+
87+
### Changes:
88+
- Updated `openapi/client/client-capitalized.yaml` (Client API)
89+
- Updated `openapi/indexing/indexing-capitalized.yaml` (Indexing API)
90+
91+
### Trigger:
92+
${{ github.event_name == 'schedule' && 'Daily automated sync' || format('Manual trigger: {0}', github.event.inputs.reason) }}
93+
94+
### Actions taken:
95+
- Downloaded latest specs from GitHub Pages
96+
- Committed changes to repository
97+
- Created this PR for review
98+
99+
---
100+
🤖 This PR was created automatically by the OpenAPI spec sync workflow.
101+
branch: sync-openapi-specs
102+
delete-branch: true
103+
labels: |
104+
automated
105+
openapi
106+
dependencies
107+
108+
- name: Enable Auto-Merge
109+
if: steps.check-changes.outputs.has_changes == 'true'
110+
uses: peter-evans/enable-pull-request-automerge@v3
111+
with:
112+
token: ${{ secrets.GITHUB_TOKEN }}
113+
pull-request-number: ${{ steps.create-pr.outputs.pull-request-number }}
114+
merge-method: squash
115+
116+
verify-build:
117+
needs: sync-specs
118+
if: needs.sync-specs.outputs.has_changes == 'true'
119+
runs-on: ubuntu-latest
120+
121+
steps:
122+
- name: Checkout repository
123+
uses: actions/checkout@v4
124+
125+
- name: Set up mise
126+
uses: jdx/mise-action@v2
127+
with:
128+
cache: true
129+
env:
130+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
131+
132+
- name: Install dependencies
133+
run: yarn install --immutable
134+
135+
- name: Verify build with new specs
136+
run: yarn build

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
.docusaurus
99
.cache-loader
1010
.changelog-cache.json
11+
.openapi-cache
1112

1213
# Misc
1314
.DS_Store

0 commit comments

Comments
 (0)