-
Notifications
You must be signed in to change notification settings - Fork 5
143 lines (127 loc) · 5.16 KB
/
trigger-client-generation.yml
File metadata and controls
143 lines (127 loc) · 5.16 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
name: Trigger Client SDK Generation
on:
workflow_dispatch:
inputs:
reason:
description: 'Reason for triggering client generation'
required: false
default: 'Manual trigger'
type: string
workflow_run:
workflows: ['Transform OpenAPI Specs']
types:
- completed
branches:
- main
permissions:
contents: read
jobs:
check:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }}
outputs:
should_trigger: ${{ steps.determine.outputs.should_trigger }}
steps:
# When triggered by workflow_run, check if transform.yml actually committed changes.
# We detect this by looking for the "Generated-by:" identifier in the commit body.
# NOTE: This identifier is defined in transform.yml - if you change it there,
# update the check here accordingly.
- name: Determine if client generation should run
id: determine
env:
GH_TOKEN: ${{ github.token }}
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "Manually triggered: ${{ github.event.inputs.reason }}"
echo "should_trigger=true" >> $GITHUB_OUTPUT
exit 0
fi
echo "Automatically triggered after successful Transform OpenAPI Specs workflow"
EXPECTED_IDENTIFIER="Generated-by: .github/workflows/transform.yml"
LAST_COMMIT=$(gh api repos/${{ github.repository }}/commits/main --jq '.commit.message')
echo "::group::Commit check details"
echo "Expected identifier: $EXPECTED_IDENTIFIER"
echo "Last commit message:"
echo "$LAST_COMMIT"
echo "::endgroup::"
if [[ "$LAST_COMMIT" == *"$EXPECTED_IDENTIFIER"* ]]; then
echo "should_trigger=true" >> $GITHUB_OUTPUT
echo "Transform committed changes, proceeding with client generation"
else
echo "should_trigger=false" >> $GITHUB_OUTPUT
echo "::notice::Skipping client generation - no meaningful spec changes were committed"
fi
trigger-clients:
runs-on: ubuntu-latest
needs: check
if: needs.check.outputs.should_trigger == 'true'
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 }}
owner: gleanwork
repositories: api-client-python,api-client-typescript,api-client-go,api-client-java
- name: Trigger Python Client SDK Generation
uses: actions/github-script@v7
with:
github-token: ${{ steps.app-token.outputs.token }}
script: |
const result = await github.rest.actions.createWorkflowDispatch({
owner: 'gleanwork',
repo: 'api-client-python',
workflow_id: 'sdk_generation.yaml',
ref: 'main',
inputs: {}
});
console.log('Python client generation triggered:', result.status);
- name: Trigger TypeScript Client SDK Generation
uses: actions/github-script@v7
with:
github-token: ${{ steps.app-token.outputs.token }}
script: |
const result = await github.rest.actions.createWorkflowDispatch({
owner: 'gleanwork',
repo: 'api-client-typescript',
workflow_id: 'sdk_generation.yaml',
ref: 'main',
inputs: {}
});
console.log('TypeScript client generation triggered:', result.status);
- name: Trigger Go Client SDK Generation
uses: actions/github-script@v7
with:
github-token: ${{ steps.app-token.outputs.token }}
script: |
const result = await github.rest.actions.createWorkflowDispatch({
owner: 'gleanwork',
repo: 'api-client-go',
workflow_id: 'sdk_generation.yaml',
ref: 'main',
inputs: {}
});
console.log('Go client generation triggered:', result.status);
- name: Trigger Java Client SDK Generation
uses: actions/github-script@v7
with:
github-token: ${{ steps.app-token.outputs.token }}
script: |
const result = await github.rest.actions.createWorkflowDispatch({
owner: 'gleanwork',
repo: 'api-client-java',
workflow_id: 'sdk_generation.yaml',
ref: 'main',
inputs: {}
});
console.log('Java client generation triggered:', result.status);
- name: Summary
run: |
echo "✅ All client SDK generation workflows have been triggered successfully!"
echo ""
echo "Triggered workflows:"
echo "- Python: https://github.com/gleanwork/api-client-python/actions"
echo "- TypeScript: https://github.com/gleanwork/api-client-typescript/actions"
echo "- Go: https://github.com/gleanwork/api-client-go/actions"
echo "- Java: https://github.com/gleanwork/api-client-java/actions"