-
Notifications
You must be signed in to change notification settings - Fork 0
265 lines (241 loc) · 8.59 KB
/
Copy pathregister-smart-clients.yml
File metadata and controls
265 lines (241 loc) · 8.59 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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
name: Register SMART Clients
on:
workflow_dispatch:
inputs:
mode:
description: "Registration mode"
required: true
type: choice
options:
- bulk-connectathon
- single-client
clients_file:
description: "Path to clients JSON file (bulk mode only)"
required: false
default: "module-config/connectathon-clients.json"
type: string
client_type:
description: "Client type (single mode only)"
required: false
type: choice
default: "smart-app-launch"
options:
- smart-app-launch
- backend-service
client_id:
description: "Client ID (single mode only)"
required: false
type: string
client_name:
description: "Client name (single mode only)"
required: false
type: string
redirect_uris:
description: "Comma-separated redirect URIs (single mode only)"
required: false
type: string
scopes:
description: "Space-separated scopes (single mode only)"
required: false
type: string
dry_run:
description: "Dry run (preview without registering)"
required: false
default: true
type: boolean
skip_existing:
description: "Skip clients that already exist"
required: false
default: true
type: boolean
issue_number:
description: "Issue number to post results to (optional)"
required: false
type: number
workflow_call:
inputs:
client_type:
description: "Client type"
required: true
type: string
client_id:
description: "Client ID"
required: true
type: string
client_name:
description: "Client name"
required: true
type: string
redirect_uris:
description: "Comma-separated redirect URIs"
required: false
default: ""
type: string
scopes:
description: "Space-separated scopes"
required: true
type: string
contact_email:
description: "Contact email"
required: false
default: ""
type: string
dry_run:
description: "Dry run"
required: false
default: false
type: boolean
issue_number:
description: "Issue number to post results to"
required: false
default: 0
type: number
secrets:
CSIRO_FHIR_AUTH_64:
required: true
permissions:
contents: read
issues: write
jobs:
# ============================================================================
# Bulk Registration (connectathon clients from JSON file)
# ============================================================================
register-bulk:
name: Register Connectathon Clients (Bulk)
runs-on: arc-runner-set
container:
image: python:3.12-slim
if: >-
github.event_name == 'workflow_dispatch' &&
inputs.mode == 'bulk-connectathon'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install dependencies
run: pip install -r scripts/requirements.txt
- name: Register clients
run: |
python scripts/register_smart_client.py \
--bulk \
--clients-file "${{ inputs.clients_file }}" \
${{ inputs.dry_run == true && '--dry-run' || '' }} \
${{ inputs.skip_existing == true && '--skip-existing' || '--no-skip-existing' }} \
--summary-file /tmp/registration-summary.json \
--github-step-summary "$GITHUB_STEP_SUMMARY"
env:
CSIRO_FHIR_AUTH_64: ${{ secrets.CSIRO_FHIR_AUTH_64 }}
- name: Post results to issue
if: inputs.issue_number != 0 && inputs.issue_number != ''
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const summary = JSON.parse(fs.readFileSync('/tmp/registration-summary.json', 'utf8'));
const dryRun = summary.dry_run ? ' (DRY RUN)' : '';
let body = `## SMART Client Bulk Registration${dryRun}\n\n`;
body += `| Metric | Value |\n|--------|-------|\n`;
body += `| Total | ${summary.total} |\n`;
body += `| Registered | ${summary.succeeded} |\n`;
body += `| Skipped (existing) | ${summary.skipped} |\n`;
body += `| Failed | ${summary.failed} |\n`;
body += `| Duration | ${summary.duration_seconds}s |\n\n`;
body += `### Results\n\n| Client ID | Type | Status |\n|-----------|------|--------|\n`;
for (const r of summary.results) {
const status = r.already_exists ? 'Skipped (exists)' : r.success ? 'Registered' : `Failed: ${r.error_message}`;
body += `| \`${r.client_id}\` | ${r.client_type} | ${status} |\n`;
}
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: parseInt('${{ inputs.issue_number }}'),
body: body,
});
# ============================================================================
# Single Client Registration (manual dispatch)
# ============================================================================
register-single-dispatch:
name: Register Single Client (Manual)
runs-on: arc-runner-set
container:
image: python:3.12-slim
if: >-
github.event_name == 'workflow_dispatch' &&
inputs.mode == 'single-client'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install dependencies
run: pip install -r scripts/requirements.txt
- name: Register client
run: |
REDIRECT_URIS_ARG=""
if [ -n "$REDIRECT_URIS" ]; then
REDIRECT_URIS_ARG="--redirect-uris $REDIRECT_URIS"
fi
SCOPES_ARG=""
if [ -n "$SCOPES" ]; then
SCOPES_ARG="--scopes $SCOPES"
fi
python scripts/register_smart_client.py \
--client-type "$CLIENT_TYPE" \
--client-id "$CLIENT_ID" \
--client-name "$CLIENT_NAME" \
$REDIRECT_URIS_ARG \
$SCOPES_ARG \
${{ inputs.dry_run == true && '--dry-run' || '' }} \
${{ inputs.skip_existing == true && '--skip-existing' || '--no-skip-existing' }} \
--summary-file /tmp/registration-summary.json \
--github-step-summary "$GITHUB_STEP_SUMMARY"
env:
CSIRO_FHIR_AUTH_64: ${{ secrets.CSIRO_FHIR_AUTH_64 }}
CLIENT_TYPE: ${{ inputs.client_type }}
CLIENT_ID: ${{ inputs.client_id }}
CLIENT_NAME: ${{ inputs.client_name }}
REDIRECT_URIS: ${{ inputs.redirect_uris }}
SCOPES: ${{ inputs.scopes }}
# ============================================================================
# Single Client Registration (called from issue-labeled workflow)
# ============================================================================
register-single-issue:
name: Register Single Client (from Issue)
runs-on: arc-runner-set
container:
image: python:3.12-slim
if: github.event_name == 'workflow_call'
steps:
- name: Install system dependencies
run: |
apt-get update
apt-get install -y git jq curl
- name: Checkout repository
uses: actions/checkout@v4
- name: Install dependencies
run: pip install -r scripts/requirements.txt
- name: Register client
id: register
run: |
REDIRECT_URIS_ARG=""
if [ -n "$REDIRECT_URIS" ]; then
REDIRECT_URIS_ARG="--redirect-uris $REDIRECT_URIS"
fi
SCOPES_ARG=""
if [ -n "$SCOPES" ]; then
SCOPES_ARG="--scopes $SCOPES"
fi
python scripts/register_smart_client.py \
--client-type "$CLIENT_TYPE" \
--client-id "$CLIENT_ID" \
--client-name "$CLIENT_NAME" \
$REDIRECT_URIS_ARG \
$SCOPES_ARG \
${{ inputs.dry_run == true && '--dry-run' || '' }} \
--skip-existing \
--summary-file /tmp/registration-summary.json \
--github-step-summary "$GITHUB_STEP_SUMMARY"
env:
CSIRO_FHIR_AUTH_64: ${{ secrets.CSIRO_FHIR_AUTH_64 }}
CLIENT_TYPE: ${{ inputs.client_type }}
CLIENT_ID: ${{ inputs.client_id }}
CLIENT_NAME: ${{ inputs.client_name }}
REDIRECT_URIS: ${{ inputs.redirect_uris }}
SCOPES: ${{ inputs.scopes }}