Version 3
Publish from Git with CI/CD

Publish from Git with CI/CD

Push to main, and every robot that changed gets a new version in its task package, published by your own pipeline.

Audience: builders and DevOps engineers

Task Engine is in private preview. To get access, contact us (opens in a new tab).

Control Room could publish robots straight from GitHub or GitLab. On Sema4.ai, your CI/CD pipeline publishes them with rcc cloud push, the same command a developer runs by hand. The templates and the script are open source, in the publish-from-git (opens in a new tab) folder of the robocorp-to-v3 repository.

How it works. A GitHub Actions workflow runs a small Python script on every push to main. The script finds the robots that changed since the last push, sets up rcc against your Sema4.ai instance, and runs rcc cloud push for each one. Each push becomes a new version of the robot's task package, and Workflows run the newest version.

Set it up on GitHub

Get the IDs

In Sema4.ai, open the task package, select Publish a version, then Publish from a terminal. The commands there show the package ID (-r) and the account ID (-w). For a robot that has no package yet, create one first by uploading it or with rcc cloud new.

Create a credential

Open the account menu, select Access credentials, and create a credential. Copy its value, in the form identifier:secret.

Add three files to your repository

Copy this from the repositoryTo
publish-from-git/github/publish-to-v3.yml.github/workflows/publish-to-v3.yml
publish-from-git/taskpackage_sync.pyv3-publish/taskpackage_sync.py
publish-from-git/v3-packages.yamlv3-publish/v3-packages.yaml

Fill in the IDs in v3-packages.yaml. Each key under packages is the folder that holds a robot's robot.yaml:

environments:
  default:
    workspace: <account id>
packages:
  robots/invoice-bot:
    default: <package id>

Add the credential and your address to GitHub

Under Settings, then Secrets and variables, then Actions, add the secret V3_RCC_CREDENTIALS with the credential, and the variable V3_URL with your Sema4.ai address, for example https://us3.sema4.ai.

Push

The Publish to v3 run lists each robot it published. To publish every robot once, for example after changing the mapping, run the workflow by hand from Actions.

The workflow runs on pushes that change robots/** or the mapping file. If your robots live somewhere else, change the paths in the workflow.

Add DEV and PROD

For production robots, put the usual lifecycle around publishing, so every change is reviewed, every merge goes to DEV first, and PROD gets only approved releases:

StageWhat happensGate
ReviewA pull request runs a plan check that lists the DEV packages the merge will publishA required review and a passing plan check on a protected main
IntegrateMerging publishes each changed robot to its DEV packageOnly through a reviewed pull request
TestRun the robot's DEV Workflow in Sema4.ai and check the resultsYour sign-off
ReleaseTag the tested commit: invoice-bot/v1.2.0 releases one robot, v1.2.0 releases all of themProtected tags, and required reviewers on the v3-prod environment
  • PROD runs exactly what DEV tested. A release tag points at a commit already on main, so the package that reaches PROD is the one DEV ran.
  • Keep DEV and PROD in separate workspaces. A robot reads the secrets, assets, and workers of the workspace it runs in, so the same names can hold DEV values in one and PROD values in the other. A -dev package next to the PROD one in a single workspace is fine for small teams and trials.
  • Roll back by re-running. Re-run the previous release tag's job, and that version is published again as the newest.

The repository's DEV and PROD guide (opens in a new tab) has the workflow file, the mapping, the GitHub rulesets and environments, and the hotfix flow. In a private repository, GitHub environments need GitHub Pro, Team, or Enterprise, and required reviewers need Enterprise Cloud.

GitLab

The same two setups exist for GitLab CI, as drafts that have not yet run on GitLab (opens in a new tab).

Good to know

The CI credential publishes as the person who created it. An access credential acts with its owner's access, in every workspace where they can build. Create it for a dedicated account where you can, keep it only in your CI secrets, and revoke it when the pipeline no longer needs it.

  • The commit isn't recorded in Sema4.ai. A version shows who published it and when, not the commit. Your release tag and the CI run are the record.
  • One way per package. A package linked to a repository with Publish from GitHub refuses rcc cloud push. Choose the pipeline or the link for each package, not both.
  • Every option. The script's options, its environment variables, and the mapping file are in the repository's reference (opens in a new tab).