This topic explains how to use the Flag Evaluations GitHub Actions integration. The integration lets you evaluate LaunchDarkly feature flags as a step in your GitHub workflow jobs and use those values in later steps.
GitHub Actions is a platform that allows you to automate, customize, and execute your software development workflows in your repository. Using LaunchDarkly feature flags, you can gain additional flexibility and control over your CI/CD pipeline.
To complete this procedure, you must have the following prerequisites:
LAUNCHDARKLY_SDK_KEY.To set up Flag Evaluations:
action.yml file: Copy and paste the eval-flags job declaration below into the jobs section in your action.yml file.action.yml in the .github/workflows directory of your repository. Paste the eval-flags job declaration below into the Edit file section.We strongly recommend that you update the uses attribute value to reference the most recent tag in the launchdarkly/gha-flags repository. This pins your workflow to a particular version of the launchdarkly/gha-flags action.
The workflow evaluates the flags listed under the flags key of the action. Each flag that the workflow evaluates must include a flag key and fallback value.
The flag key identifies the flag. The SDK serves the fallback value if LaunchDarkly is unreachable or if the flag does not have an off variation set.
Configure your SDK: Evaluating flags
In the example workflow above, the key is test-boolean-flag and the fallback value is false.
Each of the flag keys included in the job will have their evaluation output accessible at steps.<job id>.outputs.<flag key>.
In the example above the flag key test-boolean-flag is available using steps.ld.outputs.test-boolean-flag.
GitHub Actions casts all value types to string in the output.
Each time you execute this action, the action creates up to three contexts. You can view the created contexts on your Contexts list.
This action creates or updates contexts based on the following mappings:
GITHUB_ to a context with the kind GitHub.RUNNER_ to a context with the kind GitHubRunner.LD_ to a context with the kind GitHubCustomAttributes.For a list of the automatically mapped in environment variables, read GitHub’s default environment variables.
This integration currently has the following limitations:
string type.null is returned for the value.After you create the workflow, you can confirm that it’s working correctly by pushing an empty commit 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.