Use Dynamic Pickers for a Pull Request Creator Workflow
Get started with interactive Workflows to develop a Pull Request Creator Workflow.
Dynamic Pickers in Harness IDP Self-Service Workflows enable users to interact with input form fields and receive real-time options, ensuring validation for workflow creators. These dynamic pickers allow users to select input values dynamically, making workflows more interactive.
The primary goal of this tutorial is to help you understand the following concepts and features in detail:
✔ Updating Fields using Form Context
✔ Live User Validation using API Requests
These features allow users to dynamically filter results based on previous inputs and make customizable API requests with real-time validation.
Pull request creator workflow
For new hires and developers, the onboarding process can be complex and overwhelming. It often takes days for developers to become familiar with the system and start contributing effectively.
This tutorial demonstrates how to build a GitHub Pull Request Creator Workflow that significantly reduces the time required for a developer's first pull request, from days to just a few minutes. This tutorial aims to provide a detailed understanding of the various features of Dynamic Pickers.
The workflow enables developers to:
Select a repository where they want to contribute.
Validate branch details auto-fetched using Dynamic Pickers.
Provide additional details required to create a pull request.

Before you begin
Before starting, ensure you meet the following requirements:
Harness IDP is enabled for your account. Refer to this guide for setup instructions.
You have IDP Admin Role access or a role with full access to IDP resources.
Git Integration is configured and setup for your Harness IDP account.
A GitHub token is stored as a secret in Harness IDP for API authentication. You can add the token as a secret directly while creating a Backend Proxy.
Create the workflow
The workflow is built in the following steps:
Define a Backend Proxy: Establish authentication for API requests from the workflow frontend to the third-party provider (GitHub).
Create a Repository Picker: Implement a dynamic picker field in the workflow frontend to fetch available GitHub repositories.
Auto-update Repository Details: Fetch and store context data (e.g., repository name, branch, and type) and display it for user validation.
Add Live User Validation: Allow users to enter additional details and validate auto-updated information before creating a pull request.
Define a backend proxy
To enable the workflow frontend to make authenticated API requests to GitHub, a Backend Proxy is required. Read more about configuring a Backend Proxy here.
Add the backend proxy configuration
Navigate to Harness IDP and click "Configure" from the main menu.

Under the "Plugins" page, search for "Configure Backend Proxies" by Harness IDP. Ensure this plugin is enabled.

Add the following configuration in
app-config.yamlunder the "Configurations" tab:
Configuration details
github-api: Unique endpoint name for the backend proxy.target: Points to the API base URL (GitHub).pathRewrite: Ensures proper API request routing.headers: Includes the GitHub authentication token (stored as a secret in Harness IDP).
Important notes
Use a unique token name. Avoid system-defined names like GITHUB_TOKEN, as these might conflict with system variables.
The token name itself does not matter, as long as a corresponding secret is set up in Harness IDP.
Save and verifying the configuration
Click "Save Configurations" to apply the backend proxy setup.
To verify, make a request to the proxy endpoint:
https://idp.harness.io/{ACCOUNT_IDENTIFIER}/idp/api/proxy/github-api/userThe proxy endpoint URL:
https://idp.harness.io/{ACCOUNT_IDENTIFIER}/idp/api/proxy/github-api/mirrors the GitHub API base URL (https://api.github.com/), allowing you to use any GitHub API endpoint by appending the correct path.For more details on consuming Harness IDP APIs, refer to the Harness API Documentation.
Once verified, the backend proxy is ready to authenticate API requests within the workflow.
Create a repository picker
Now, let us define the Workflow Frontend in the Workflow YAML configuration. A Repository Picker dynamically fetches GitHub repositories based on the provided GitHub username. This feature is based on conditional API requests in self service workflows.
Read more about conditional API requests in Dynamic Pickers here.
Required fields
GitHub Username: A text field that accepts a GitHub username as input.
Choose Repository: A Dynamic Picker field that fetches and displays repositories based on the entered username.
YAML configuration

YAML breakdown
gitUsername: A simple text input field that accepts a GitHub username as a string. This input is required to fetch repositories associated with the user.repoPicker: A Dynamic Picker field that retrieves and displays repositories based on the GitHub username input.
Key attributes
ui:field: Must be set toSelectFieldFromApito enable dynamic selection.title,description, andplaceholder: Text fields that guide the user on what information to enter.path: Specifies the API endpoint format:proxy/endpoint-name/API-path
Here, endpoint-name is github-api, as defined in the backend proxy.
Dynamic path reference
The gitUsername variable is referenced in the Dynamic Picker field path, ensuring that when a user enters a GitHub username, the picker dynamically fetches and displays all associated repositories.
path: proxy/github-api/users/{{ parameters.gitUsername }}/repos
This setup ensures that the repository list updates dynamically based on the entered username.
Auto-update repository details
Once a repository is selected, the workflow should automatically fetch and display repository details.
Read more about auto-updating input fields in Workflows here.
Required fields
Repository Name: Name of the repsoitory, Auto-fetched, read-only.
Repository Branch: Origin Branch of the repository, Auto-fetched, but editable.
Repository Type: Visibility of the repository, Auto-fetched, read-only.
YAML configuration

YAML breakdown
To make the workflow more dynamic, repository details such as name, branch, and type need to be fetched and displayed automatically.
Data fields stored in form context
The following values are retrieved and stored in form context:
repoName: Repository namebranch: Default branchtype: Repository visibility (Public/Private)
Define context data
Context data is stored in the ui:options section within the Dynamic Picker field using the setContextDataproperty:
Auto-update input fields
Once context data is set, we use getContextData to auto-update the input fields dynamically.
repositoryName and typeName are read-only (using the
readonlytag) fields (users cannot modify them)originBranchName remains editable so users can specify a branch if required.
Field References
originBranchNameis the frontend input field.formContext.branchretrieves and automatically updates this field based on the GitHub API response.
Add live user validation
Before creating a pull request, users should validate auto-updated details and provide additional inputs.
Read more about adding live user validation in Workflows here.
Required fields
PR Title: User input for the Pull Request title.
New Branch: User input for the branch name where changes are implemented.
Custom Button: Triggers GitHub API call for validation and PR creation.
YAML configuration

YAML breakdown
To finalize the workflow, we need a validation button that allows users to verify auto-fetched details and create a pull request.
Custom validation button
customValidate: The custom button field for validation and PR creation.ui:field: Must be set to ValidateAndFetch to trigger validation and API calls.
Configurable options in ui:options
button: Defines and adds the "Create a Pull Request" button.path: Specifies the API endpoint for the PR creation request.setContextData: Stores additional context data upon API request execution.
prUrl: A workflow variable that stores the pull request URL.html_url: The API response field containing the PR URL.
Define the API request
The GitHub API request is structured as a POST request, containing the necessary fields for PR creation. Read more about making a POST API request here
API Request Breakdown
title: The Pull Request title, dynamically retrieved from the user input fieldtitlePR.head: The changes source branch, retrieved fromnewBranch.base: The destination branch (default branch of the repository).
Show form context live
At any time, if you need to display the Form Context live in your Workflow Frontend for debugging purposes, you can use the following format:
Read more about the syntax here.
Workflow YAML
Additional notes
Added a new field in the frontend that retrieves and displays the "Pull Request URL" stored in the Form Context.
No specific Action has been added for this tutorial, as its primary purpose is to help users understand the features and concepts.
Example YAML

Last updated
Was this helpful?