Step 1: Register the Scaffolder templates
This Workflow uses two Scaffolder templates: Follow the instructions to register the Scaffolder templates in Cortex.Step 2: Start creating the Workflow
Follow the steps in the documentation to create a Workflow and configure its basic settings.Step 3: Add blocks to the Workflow
The instructions on this page describe how to create this Workflow in the Cortex UI, but it is also possible to copy the Workflow YAML and add it to your workspace via the Cortex CLI. This allows you to quickly set up the example configuration then iterate on it for your own use case. Expand the tile below to learn more.Workflow YAML instructions
Workflow YAML instructions
To upload the Workflow example YAML into your workspace:
- Save the Workflow example YAML file below:
- Use the Cortex CLI to run this command, using the path to your Workflow YAML file:
cortex workflows create -f <path-to-your-workflow.yaml>
Data transformation
Data transformation
Create a data transformation to take the Workflow initiator’s name and append
-repo to it:- Click + in the center of the page. In the block library modal, choose Data transformation.
- In the block configuration side panel, enter a name and unique slug for this block.
- In this example, we use the name
Transform user infoand the slugtransform-user-info.
- In this example, we use the name
- Add a jq expression to take the initiator’s name and add
-repoto it:
- At the bottom of the side panel, click Save.
Scaffolder
Scaffolder
This block creates a new repository in your connected Git integration, using templating to apply the output of the previous block to the Scaffolder configuration.
- Click + in the center of the page. In the block library modal, select the Scaffolder block.
- In the side panel, enter a name and unique slug for the block.
- In this example, we use the name
Scaffold Hello Org Repoand the slugscaffold-hello-org.
- In this example, we use the name
- Under Scaffolder template, select your template. In this example, we use
Hello Org Template. - Select the option to Create a new repo.
- Add override variables. The Variable dropdown pulls in all the variables that are able to be overridden in the Git provider and in the Scaffolder template. In this example, we apply the following override:
- repo_name:
actions.transform-user-info.outputs.result- This overrides the Repo Name field with the output of the “Transform user info” block earlier in the Workflow.
- repo_name:
- At the bottom of the side panel, click Save.
Trigger GitHub workflow
Trigger GitHub workflow
This block triggers Terraform infrastructure in GitHub.
- Click + in the center of the page. In the block library modal, select the GitHub > Trigger workflow block.
- In the side panel, enter a name and unique slug for the block.
- In this example, we use the name
Terraform Infrastructure Provisioningand the slugtrigger-workflow.
- In this example, we use the name
- Configure the block:
- Repository: Enter your repository name.
- Ref: Enter the Git reference to trigger the workflow on, e.g.
main. - Workflow ID or file name: Enter the ID of the GitHub workflow or the file name of the workflow file.
- In our example, we added
main.yaml. Note that this should be just the file name and not the path to the file.
- In our example, we added
- Inputs: Optionally enter key-value pairs to pass to the workflow.
- In our example, we added:
{"user": "{{context.initiatedBy.name}}"}
- In our example, we added:
- At the bottom of the side panel, click Save.
Scaffolder
Scaffolder
This block opens a Pull Request to set up an RDS instance, using templating to apply the output of the previous block to the Scaffolder configuration.
- Click + in the center of the page. In the block library modal, select the Scaffolder block.
- In the side panel, enter a name and unique slug for the block.
- In this example, we use the name
Open PR with RDS terraformand the slugscaffold-rds-terraform.
- In this example, we use the name
- Under Scaffolder template, select your template. In this example, we use
Terraform RDS Template. - Select the option to Open a pull request.
- Add override variables. The Variable dropdown pulls in all the variables that are able to be overridden in the Git provider and in the Scaffolder template. In this example, we apply the following override:
- publisherRepoFullName:
actions.scaffold-hello-org.outputs.response.gitURL- This overrides the Repo Name field with the output of the “Scaffold Hello Org Repo” block earlier in the Workflow.
- publisherRepoFullName:
- At the bottom of the side panel, click Save.
Slack message
Slack message
In this step, we send a templated message via Slack informing the user that their test environment is ready.
- Click + in the center of the page. In the block library modal, select the Slack block.
- In the side panel, enter a name and unique slug for the block.
- In this example we use the name
Notify developerand the slugnotify-developer.
- In this example we use the name
- Select a Slack channel name.
- Enter text for the message that will be sent via Slack. In our example, we use the following:
- Save the block.
Step 4: Run the Workflow
When you run the Workflow, the following events happen:- The Data transformation block runs, which produces a repository name for the user based on your specified naming convention.
- The Scaffolder runs, creating a new repository. The repo’s name is based on the output of the previous block.
- The GitHub “Trigger a workflow” block runs, which provisions Terraform infrastructure.
- The second Scaffolder block runs, which opens a Pull Request to set up an RDS instance.
- The Slack block runs, which sends a Slack message to the user to let them know that their test environment is ready.