Skip to content

Commit 998c825

Browse files
fix: deployment pipeline (#81)
Remove auto-trigger-code-samples and instead run generate-code-samples every 4 hours. The previous setup would trigger generate-code-samples, but none of the downstream workflows (the next one being .github/workflows/deploy-pages.yml). The rules for GitHub are as follows: If workflow A triggers workflow B in a way that is "automated", then B will run but its completion will not trigger downstream workflows C. "automated" here is determined by the use of `GITHUB_TOKEN` gh workflow run generate-code-samples.yml implicitly uses `GITHUB_TOKEN`. The current setup means that most of the pipeline runs redundantly (e.g. we will generate code samples and check them in even with no changes) up until the glean developer site's trigger-redeploy.yml[^1] which exits early if there are no changes. [1]: https://github.com/gleanwork/glean-developer-site/blob/8fa1fb6cfb44c457ed135eca678d7a9da82af4f4/.github/workflows/trigger-redeploy.yml#L1-L115
1 parent 0a4a266 commit 998c825

File tree

3 files changed

+26
-64
lines changed

3 files changed

+26
-64
lines changed

.github/workflows/auto-trigger-code-samples.yml

Lines changed: 0 additions & 59 deletions
This file was deleted.

.github/workflows/generate-code-samples.yml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@ name: Generate Code Samples
33
on:
44
workflow_dispatch:
55

6+
# Run every 4 hours to check if all client releases are ready
7+
schedule:
8+
- cron: '0 */4 * * *'
9+
610
permissions:
711
contents: write
812
jobs:
9-
generate-samples:
13+
check-and-generate-samples:
1014
runs-on: macos-latest
1115

1216
steps:
@@ -24,25 +28,41 @@ jobs:
2428
- name: Install dependencies
2529
run: pnpm install --frozen-lockfile
2630

31+
- name: Check if all client releases have matching SHAs
32+
id: check
33+
run: |
34+
if pnpm run check-client-releases; then
35+
echo "clients_ready=true" >> $GITHUB_OUTPUT
36+
else
37+
echo "clients_ready=false" >> $GITHUB_OUTPUT
38+
fi
39+
env:
40+
GH_TOKEN: ${{ github.token }}
41+
2742
- name: Generate client code samples
43+
if: github.event_name == 'workflow_dispatch' || steps.check.outputs.clients_ready == 'true'
2844
run: speakeasy run -s glean-client-merged-code-samples-spec
2945
env:
3046
SPEAKEASY_API_KEY: ${{ secrets.SPEAKEASY_API_KEY }}
3147

3248
- name: Generate indexing code samples
49+
if: github.event_name == 'workflow_dispatch' || steps.check.outputs.clients_ready == 'true'
3350
run: speakeasy run -s glean-index-merged-code-samples-spec
3451
env:
3552
SPEAKEASY_API_KEY: ${{ secrets.SPEAKEASY_API_KEY }}
3653

3754
- name: Running code sample transformers
55+
if: github.event_name == 'workflow_dispatch' || steps.check.outputs.clients_ready == 'true'
3856
run: pnpm transform:merged_code_samples_specs
3957

4058
- name: Copy specs into final_specs
59+
if: github.event_name == 'workflow_dispatch' || steps.check.outputs.clients_ready == 'true'
4160
run: |
4261
cp -r ./modified_code_samples_specs/client_rest.yaml ./final_specs/client_rest.yaml
4362
cp -r ./modified_code_samples_specs/indexing.yaml ./final_specs/indexing.yaml
4463
4564
- name: Commit changes
65+
if: github.event_name == 'workflow_dispatch' || steps.check.outputs.clients_ready == 'true'
4666
uses: ./.github/actions/git-commit
4767
with:
4868
commit_message: 'Update code samples'

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,10 @@ In order to roll out changes from the upstream original source repo all the way
213213
- [gleanwork/api-client-typescript](https://github.com/gleanwork/api-client-typescript)
214214
- [gleanwork/api-client-go](https://github.com/gleanwork/api-client-go)
215215
7. 🤖CI in each of the API Client repos releases to their respective package managers
216-
8. 🤖[auto-trigger-code-samples.yml](https://github.com/gleanwork/open-api/actions/workflows/auto-trigger-code-samples.yml) checks every 4 hours if all API Client releases match the expected SHA, and triggers [generate-code-samples.yml](https://github.com/gleanwork/open-api/actions/workflows/generate-code-samples.yml) when ready
216+
8. 🤖[generate-code-samples.yml](https://github.com/gleanwork/open-api/actions/workflows/generate-code-samples.yml) checks every 4 hours if all API Client releases match the expected SHA and regenerates code samples if they do
217217
9. 🤖CI in this repo runs the [deploy-pages.yml](https://github.com/gleanwork/open-api/actions/workflows/deploy-pages.yml) workflow to deploy the final specs to GitHub Pages
218218
10. 🤖CI in this repo runs [trigger-developer-site-redeploy.yml](https://github.com/gleanwork/open-api/actions/workflows/trigger-developer-site-redeploy.yml)
219-
11. 🤖CI in [gleanwork/glean-developer-site](https://github.com/gleanwork/glean-developer-site) publishes a PR to update the developer site
220-
12. 👷Merge the [gleanwork/glean-developer-site](https://github.com/gleanwork/glean-developer-site) PR from step 11
221-
13. 🤖Vercel [redeploys developers.glean.com](https://vercel.com/glean-developers/glean-developer-site)
219+
- `trigger-developer-site-redeploy` checks for changes and aborts early if there are none
220+
- otherwise it publishes a PR to [gleanwork/glean-developer-site](https://github.com/gleanwork/glean-developer-site)
221+
11. 👷Merge the [gleanwork/glean-developer-site](https://github.com/gleanwork/glean-developer-site) PR from step 11
222+
12. 🤖Vercel [redeploys developers.glean.com](https://vercel.com/glean-developers/glean-developer-site)

0 commit comments

Comments
 (0)