Categorygithub.com/launchdarkly/cr-flags
modulepackage
0.7.0-rc.4
Repository: https://github.com/launchdarkly/cr-flags.git
Documentation: pkg.go.dev

# README

LaunchDarkly Find Code References in Pull Request GitHub action

Adds a comment to a pull request (PR) whenever a feature flag reference is found in a PR diff.

An example code references PR comment

Permissions

This action requires a LaunchDarkly access token with read access for the designated project-key. Access tokens should be stored as an encrypted secret.

To add a comment to a PR, the repo-token used requires write permission for PRs. You can also specify permissions for the workflow with:

permissions:
  pull-requests: write

Usage

Basic:

on: pull_request

jobs:
  find-flags:
    runs-on: ubuntu-latest
    name: Find LaunchDarkly feature flags in diff
    steps:
      - name: Checkout
        uses: actions/checkout@v3
      - name: Find flags
        uses: launchdarkly/[email protected]
        id: find-flags
        with:
          project-key: default
          environmet-key: production
          access-token: ${{ secrets.LD_ACCESS_TOKEN }}
          repo-token: ${{ secrets.GITHUB_TOKEN }}

Use outputs in workflow:

on: pull_request

jobs:
  find-feature-flags:
    runs-on: ubuntu-latest
    name: Find LaunchDarkly feature flags in diff
    steps:
      - name: Checkout
        uses: actions/checkout@v3
      - name: Find flags
        uses: launchdarkly/[email protected]
        id: find-flags
        with:
          project-key: default
          environmet-key: production
          access-token: ${{ secrets.LD_ACCESS_TOKEN }}
          repo-token: ${{ secrets.GITHUB_TOKEN }}

      # Add or remove labels on PRs if any flags have changed
      - name: Add label
        if: steps.find-flags.outputs.any-changed == 'true'
        run: gh pr edit $PR_NUMBER --add-label ld-flags
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          PR_NUMBER: ${{ github.event.pull_request.number }}
      - name: Remove label
        if: steps.find-flags.outputs.any-changed == 'false'
        run: gh pr edit $PR_NUMBER --remove-label ld-flags
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          PR_NUMBER: ${{ github.event.pull_request.number }}

Flag aliases

This action has full support for code reference aliases. If the project has an existing .launchdarkly/coderefs.yaml file, it will use the aliases defined there.

You can find more information on aliases at launchdarkly/ld-find-code-refs.

Monorepos

This action does not support monorepos or searching for flags across LaunchDarkly projects.

Inputs

parameterdescriptionrequireddefault
repo-tokenToken to use to authorize comments on PR. Typically the GITHUB_TOKEN secret or equivalent github.token.true
access-tokenLaunchDarkly access tokentrue
project-keyLaunchDarkly project keyfalsedefault
environment-keyLaunchDarkly environment key for creating flag linksfalseproduction
placeholder-commentComment on PR when no flags are found. If flags are found in later commits, this comment will be updated.falsefalse
include-archived-flagsScan for archived flagsfalsetrue
max-flagsMaximum number of flags to find per PRfalse5
base-uriThe base URI for the LaunchDarkly server. Most users should use the default value.falsehttps://app.launchdarkly.com

Outputs

parameterdescription
any-modifiedReturns true if any flags have been added or modified in PR
modified-flagsSpace-separated list of flags added or modified in PR
modified-flags-countNumber of flags added or modified in PR
any-removedReturns true if any flags have been removed in PR
removed-flagsSpace-separated list of flags removed in PR
removed-flags-countNumber of flags removed in PR
any-ChangedReturns true if any flags have been changed in PR
changed-flagsSpace-separated list of flags changed in PR
changed-flags-countNumber of flags changed in PR

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author