Bots with CI/CD
# support
c
Is there a way to deploy all bots in a given directory? I would like to create a CI/CD process that deploys our bots to our Medplum projects in a pipeline when we merge our PRs.
r
Hi @Charlie from Imagine - check out our "Bots in Production" doc to see how to integrate Bots into your SDLC: https://www.medplum.com/docs/bots/bots-in-production#deploying-your-bot
You can use the medplum cli (
medplum bot deploy
) to incorporate the bot deployment into your CI/CD pipleline
c
Yeah, those docs are dealing with 1 bot at a time.
r
We don't have a way to deploy by-folder just yet, but we do support wildcard for deploy multiple bots: https://www.medplum.com/docs/bots/bots-in-production#deploying-your-bot
c
Ohhhh
I completely missed that wildcard bit
Thats exactly what we need!
r
So if you named all your bots in
medplum.config.json
with a pattern of
[botname]-production
, then you can deploy them all in a single command
c
Yep, this is better than by dir
Thanks Rahul!
@rahul1 is there a way to manager subscriptions with CI/CD too?
r
i.e add / remove a subscription to the Bots from CI/CD? There isn't a 1-command "deploy" option, but you can use the medplum CLI to create/update subsciptions, as they are just another resource: https://www.medplum.com/docs/cli#post
c
@rahul1 when deploying from automation, should you have to run
medplum login
?
r
You should not need to you. You can create a
ClientApplication
for CI/CD, and then set env vars for your credentials
Let me get that info to you
c
Hmmm I saw that in the bot in production docs, but when testing locally it still sent me to a browser.
Maybe I didnt set things right 🤔
r
If those env vars are set, hopefully shouldn't need to run
login
at all
let me know if that isn't wokring
MEDPLUM_CLIENT_ID
MEDPLUM_CLIENT_SECRET
Please let me know if this workflow is not working
You could also use the command line params as well
Copy code
medplum deploy-bot --help
Usage: medplum deploy-bot [options] <botName>

Deploy the bot to AWS

Options:
  --client-id <clientId>               FHIR server client id
  --client-secret <clientSecret>       FHIR server client secret
  --base-url <baseUrl>                 FHIR server base url
  --token-url <tokenUrl>               FHIR server token url
  --authorize-url <authorizeUrl>       FHIR server authorize url
  --fhir-url-path <fhirUrlPath>        FHIR server url path
  --scope <scope>                      JWT scope
  --access-token <accessToken>         Access token for token exchange authentication
  --callback-url <callbackUrl>         Callback URL for authorization code flow
  --subject <subject>                  Subject for JWT authentication
  --audience <audience>                Audience for JWT authentication
  --issuer, <issuer>                   Issuer for JWT authentication
  --private-key-path <privateKeyPath>  Private key path for JWT assertion
  --audience <audience>                Audience for JWT assertion
  -p, --profile <profile>              Profile name
  --auth-type <authType>               Type of authentication (choices: "basic", "client-credentials", "authorization-code", "jwt-bearer", "token-exchange", "jwt-assertion")
  -h, --help                           display help for command
161 Views