CI/CD solution to migrate a local solution to a target instabase environment.
The solution uses Instabase APIs and CI tooling to promote solutions between environments. Template CI pipelines for GitHub Actions and Azure DevOps are provided and should be updated to suit customer's needs.
The Python promote_solution.py
script calls Instabase APIs and can execute the following steps when the corresponding flags are passed in:
--compile_source_solution
- Compiles solution in source environment in path specified in
SOURCE_SOLUTION_DIR
environment variable.
- Compiles solution in source environment in path specified in
--publish_source_solution
- Publishes the latest version of the solution in the source environment to Deployed Solutions
--promote_solution_to_target
- Uploads to the solution to the target environment
--publish_target_solution
- Publishes the latest version of the solution in the target environment to Deployed Solutions. Use the
--local
flag to upload code in the git repository
- Publishes the latest version of the solution in the target environment to Deployed Solutions. Use the
--upload_dependencies
- Uploads and publishes the solution dependencies to the target environment based on dependencies listed in
package.json
- Uploads and publishes the solution dependencies to the target environment based on dependencies listed in
--download_ibsolution
- Downloads the
.ibsolution
file to the local filesystem
- Downloads the
--set_github_actions_env_var
- Sets
PACKAGE_VERSION
environment variable to be used in later steps in the GitHub Actions pipleline
- Sets
--set_azure_devops_env_var
- Sets
PACKAGE_VERSION
environment to be used in later steps in the Azure DevOps pipeline
- Sets
--local
- To be used alongside above flags. This will promote a solution from the codebase rather than a remote Instabase environment
--remote
- To be used alongside above flags. This will promote a solution from a source Instbase environment
--local_flow
- Performs series of above steps for a local workflow
--remote_flow
- Performs series of above steps for a remote workflow,
--compile_source_solution
,--set_azure_devops_env_var
, and--set_github_actions_env_var
are not included in these so need to be used too
- Performs series of above steps for a remote workflow,
--marketplace
- Publishes solution to Marketplace. If not used then Deployed Solutions will be used
--compile_source_solution
- Compiles solution in source environment in path specified in
SOURCE_SOLUTION_DIR
environment variable.
- Compiles solution in source environment in path specified in
--deploy_source_solution
- Publishes the latest version of the solution in the source environment to Deployed Solutions
--promote_solution_to_target
- Uploads to the solution to the target environment
--deploy_target_solution
- Publishes the latest version of the solution in the target environment to Deployed Solutions
--upload_dependencies
- Uploads and publishes the solution dependencies to the target environment based on dependencies listed in
package.json
- Uploads and publishes the solution dependencies to the target environment based on dependencies listed in
--download_ibsolution
- Downloads the
.ibsolution
file to the local filesystem
- Downloads the
--set_github_actions_env_var
- Sets
PACKAGE_VERSION
environment variable to be used in later steps in the GitHub Actions pipleline
- Sets
--set_azure_devops_env_var
- Sets
PACKAGE_VERSION
environment to be used in later steps in the Azure DevOps pipeline
- Sets
--remote_flow
- Performs series of above steps for a remote workflow,
--compile_source_solution
,--set_azure_devops_env_var
,--download_ibsolution
, and--set_github_actions_env_var
are not included in these so need to be used too
- Performs series of above steps for a remote workflow,
The local-github-actions
automated pipeline runs on successful merge to main, so the main branch of the project should mirror the target environment. The remote-github-actions-workflow
is manually run.
The pipeline sets environment variables from GitHub secrets and variables and runs the Python script. It then creates a release stores the downloaded .ibsolution
file as an artifact.
If you're not using CI tooling and running the script locally you will need to set the below environment variables. There is an option to store these variables in a .env
file which will get loaded in using load_dotenv()
at the beginning of the script
- Set the following git secrets in Settings > Secrets and Variables > Actions:
- SOURCE_IB_API_TOKEN API token for source environment. Ideally both tokens should belong to a service account
- TARGET_IB_API_TOKEN API token for target environment
- Set git variables in the same place:
- SOURCE_IB_HOST e.g. "https://solution-eng.aws.sandbox.instabase.com"
- SOURCE_WORKING_DIR Path in source IB environment's filesystem to use for downloading dependencies
- SOURCE_SOLUTION_DIR Path to the solution directory in the source Instabase environment
- LOCAL_SOLUTION_DIR Directory in local repository that contains IB solution code, if using a remote flow leave a blank string
- REL_FLOW_PATH Path to flow relative to Instabase solution e.g. in "path/to/solution/Flow/some_flow.ibflow" where "path/to/solution" is
SOURCE_SOLUTION_DIR
it would be "Flow/some_flow.ibflow" - SOURCE_COMPILED_SOLUTIONS_PATH Path to where
.ibsolution
files are generated. This will usually be one level higher than theSOURCE_SOLUTION_DIR
- TARGET_IB_HOST e.g. "https://instabase.com"
- TARGET_IB_PATH Path in the target IB environment where the solution will get uploaded
- Copy
ib_cicd
folder into repository and move one of the.yml
template workflow files into a.GitHub/workflows
folder
- Set the following git secrets in Settings > Secrets and Variables > Actions:
- SOURCE_IB_API_TOKEN API token for source environment. Ideally both tokens should belong to a service account
- TARGET_IB_API_TOKEN API token for target environment
- Set git variables in the same place:
- SOURCE_IB_HOST e.g. "https://solution-eng.aws.sandbox.instabase.com"
- SOURCE_WORKING_DIR Path in source IB environment's filesystem to use for downloading dependencies and storing ibsolution files
- TARGET_IB_HOST e.g. "https://instabase.com"
- TARGET_IB_PATH Path in the target IB environment where the solution will get uploaded
- SOLUTION_BUILDER_NAME Name of solution builder project
- FLOW_NAME Name of flow to promote
- WORKSPACE_DRIVE_PATH Path in source IB environment's filesystem to the drive where the solution builder project is stored, e.g. hannahroiter/ci-cd/fs/Instabase Drive
- DEPENDENCIES String representation of list of model and marketplace package dependencies in the format
model_name==0.0.1,package_name==0.4.5,second_package==0.0.1
- Copy
ib_cicd
folder into repository and move one of the.yml
template workflow files into a.GitHub/workflows
folder
- Develop in IB environment.
- Once happy with changes checkout a new git branch and copy the solution directory into codebase.
- Make sure this includes a
package.json
file and anicon.png
at the top level of the solution code, bump the version inpackage.json
- Include any dependencies in the
package.json
file in the format:"dependencies": { "models": ["model_for_cicd==0.0.1"], "dev_exchange_packages": ["package_for_cicd==0.0.1"] }
- If using Deployed solutions, ensure the
package.json
file includesowner
andvisibility
fields - Any final changes e.g. linting
- Push local branch to git
- Pull request to main
- On merge the GitHub actions workflow will:
- Run the Python script with
--local_flow
parameters (see above for steps) - Create a GitHub release with tag equal to the version stored in
package.json
- Upload the
.ibsolution
file to the release artifacts
- Run the Python script with
- Develop in IB environment.
- If in a development environment, bump up the version in
package.json
and ensure thatpackage.json
andicon.png
files are in the top level of the directory - If using Deployed solutions, ensure the
package.json
file includes fieldsowner
set toIB_DEPLOYED
andvisibility
set toPUBLIC
- Manually run the GitHub actions workflow which will:
- Run the Python script with
--remote_flow
parameters (see above for steps). If needed also pass in the--compile_solution
parameter (likely to be needed in a DEV -> UAT workflow but not in UAT -> PROD) - Commit and push the
.ibsolution
file to the repository - Create a GitHub release with tag equal to the version stored in
package.json
- Upload the
.ibsolution
file to the release artifacts
- Run the Python script with
- This will compile the solution in the source environment, promote it to the target environment, and store the
.ibsolution
file in the GitHub release
- Develop in IB environment.
- Manually run the Github actions workflow which will:
- Run the
promote_sb_solution.py
python script with--remote_flow
parameters, include--compile_source_solution
parameter if moving a solution builder project from DEV -> UAT. - Commit and push the
.ibsolution
file to the repository - Create a GitHub release with tag equal to the version of the promoted solution
- Upload the
.ibsolution
file to the release artifacts
- Run the
- This will compile the solution in the source environment, promote it to the target environment, and store the
.ibsolution
file in the GitHub release
"name": "Form W-2",
"version": "0.0.2",
"short_description": "Automatically process Form W-2",
"long_description": "Extract key fields from Tax Form W-2 in the United States",
"authors": [
"Instabase"
],
"solution_type": "ibflowbin",
"accelerator_type": [
"solution"
],
"industry": [
"Financial Services"
],
"business_vertical": [
"Retail & Consumer Banking"
],
"use_case": [
"Account Opening"
],
"icon_file": "icon.png",
"beta": true,
"encryption_config": {
"encryption_type": "v1"
},
"dependencies": {
"models": ["model_for_cicd==0.0.1"],
"dev_exchange_packages": ["package_for_cicd==0.0.1"]
},
"owner": "IB_DEPLOYED",
"visibility": "PUBLIC"
}```