-
Notifications
You must be signed in to change notification settings - Fork 5
78 lines (65 loc) · 2.65 KB
/
generate-code-samples.yml
File metadata and controls
78 lines (65 loc) · 2.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
name: Generate Code Samples
on:
workflow_dispatch:
# Run every 4 hours to check if all client releases are ready
schedule:
- cron: '0 */4 * * *'
permissions:
contents: write
jobs:
check-and-generate-samples:
runs-on: macos-latest
steps:
- name: Generate App Token
id: app-token
uses: actions/create-github-app-token@v2
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ steps.app-token.outputs.token }}
- name: Set up mise
uses: jdx/mise-action@v2
with:
cache: true
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Check if all client releases have matching SHAs
id: check
run: |
if pnpm run check-client-releases; then
echo "clients_ready=true" >> $GITHUB_OUTPUT
else
echo "clients_ready=false" >> $GITHUB_OUTPUT
fi
env:
GH_TOKEN: ${{ github.token }}
- name: Generate client code samples
if: github.event_name == 'workflow_dispatch' || steps.check.outputs.clients_ready == 'true'
run: speakeasy run -s glean-client-merged-code-samples-spec
env:
SPEAKEASY_API_KEY: ${{ secrets.SPEAKEASY_API_KEY }}
- name: Generate indexing code samples
if: github.event_name == 'workflow_dispatch' || steps.check.outputs.clients_ready == 'true'
run: speakeasy run -s glean-index-merged-code-samples-spec
env:
SPEAKEASY_API_KEY: ${{ secrets.SPEAKEASY_API_KEY }}
- name: Running code sample transformers
if: github.event_name == 'workflow_dispatch' || steps.check.outputs.clients_ready == 'true'
run: pnpm transform:merged_code_samples_specs
- name: Copy specs into final_specs
if: github.event_name == 'workflow_dispatch' || steps.check.outputs.clients_ready == 'true'
run: |
cp -r ./modified_code_samples_specs/client_rest.yaml ./final_specs/client_rest.yaml
cp -r ./modified_code_samples_specs/indexing.yaml ./final_specs/indexing.yaml
- name: Commit changes
if: github.event_name == 'workflow_dispatch' || steps.check.outputs.clients_ready == 'true'
uses: ./.github/actions/git-commit
with:
commit_message: 'Update code samples'
file_patterns: 'merged_code_samples_specs/* modified_code_samples_specs/* final_specs/* .speakeasy/*'
github_token: ${{ steps.app-token.outputs.token }}