Code references are only available to customers on select plans. To learn more, read about our pricing. To upgrade your plan, contact Sales.
If you’re on a Developer or Foundation plan, instead you can use the Flag Code References in Pull Request GitHub Action.
LaunchDarkly has multiple integrations with GitHub Actions. To learn more, read about the LaunchDarkly integrations Find Code References in Pull Request and Flag Evaluations.
This topic explains how to use the ld-find-code-refs utility with GitHub Actions to automatically populate code references in LaunchDarkly. To learn more about the utility and check for the latest version, read LaunchDarkly Code References with GitHub code references.
To complete this procedure, you must have the following prerequisites:
code-reference-repository resource, either through a base role, a LaunchDarkly-provided project role, or another role that you have created. The token must be stored as a repository secret titled LD_ACCESS_TOKEN. To learn more, read API access tokens and Code reference actions.To set up GitHub code references:
If you already have an action.yml file: Copy and paste the launchDarklyCodeReferences job declaration below into the jobs section in your action.yml file.
If you don’t already have a workflow file: Create a new file titled action.yml in the .github/workflows directory of your repository. Paste the following code in the Edit file section:
We strongly recommend that you update the second uses attribute value to reference the most recent tag in the launchdarkly/find-code-references repository. This pins your workflow to a particular version of the launchdarkly/find-code-references action.
You do not need to have this branch merged into the main branch for code references to appear in the LaunchDarkly user interface (UI). Code references will appear for this newly created branch.
As shown in the example above, the workflow should run on the push event and contain an action provided by the launchdarkly/find-code-references repository.
Include the LD_ACCESS_TOKEN as a secret, and include a new environment variable containing your LaunchDarkly project key. This is represented by YOUR_PROJECT_KEY in the above example. Do not use an environment’s SDK key, mobile key, or client-side ID for this purpose. To learn how to find your project key, read Project keys.
After you create the workflow, you can confirm that it’s working correctly by creating a new pull request with the workflow file and verifying that the newly created action succeeds.
If the action fails, there may be a problem with your configuration. To investigate, review the action’s logs to view any error messages.
You can configure find-code-references with additional inputs to enable more functionality. You can find additional configuration options at the bottom of the LaunchDarkly Code References marketplace page.
In addition to inputs, you can skip searching files and directories using a .ldignore file.
You can also use the .launchdarkly/coderefs.yaml file for advanced configuration options, such as configuring custom delimiters and aliases for your flag keys.