From df5dc6051feafe982b6b50a1b174123ac8077922 Mon Sep 17 00:00:00 2001 From: Tony Knopp Date: Thu, 13 Aug 2026 09:14:28 -0400 Subject: [PATCH] chore: update to ld-find-code-refs 2.17.0 --- Dockerfile | 2 +- README.md | 37 ++++++++++++- docker/action.yml | 129 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 165 insertions(+), 3 deletions(-) create mode 100644 docker/action.yml diff --git a/Dockerfile b/Dockerfile index b9c75e1..ffc39fd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM launchdarkly/ld-find-code-refs-github-action:2.16.0 +FROM launchdarkly/ld-find-code-refs-github-action:2.17.0 LABEL com.github.actions.name="LaunchDarkly Code References" LABEL com.github.actions.description="Find references to feature flags in your code." diff --git a/README.md b/README.md index 0041855..218cd9c 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ jobs: with: fetch-depth: 11 # This value must be set if the lookback configuration option is not disabled for find-code-references. Read more: https://github.com/launchdarkly/ld-find-code-refs#searching-for-unused-flags-extinctions - name: LaunchDarkly Code References - uses: launchdarkly/find-code-references@v2.16.0 + uses: launchdarkly/find-code-references@v2.17.0 with: accessToken: ${{ secrets.LD_ACCESS_TOKEN }} projKey: LD_PROJECT_KEY @@ -40,6 +40,39 @@ Commit this file under a new branch. Submit as a PR to your code reviewers to be As shown in the above example, the workflow should run on the `push` event, and contain an action provided by the [launchdarkly/find-code-references repository](https://github.com/launchdarkly/find-code-references). The `LD_ACCESS_TOKEN` configured in the previous step should be included as a secret, as well as a new environment variable containing your LaunchDarkly project key. +## Using a private or mirrored container registry + +The root Action (`launchdarkly/find-code-references@v2`) is a Docker container action. GitHub always pulls its image from the registry hardcoded in that Action's Dockerfile (Docker Hub), and that image reference cannot be overridden with an input. + +If your organization must pull images through an internal registry or Docker Hub proxy, use the optional **`docker`** entry point in the same Action repository. It accepts a `dockerImage` input and runs the scanner with `docker run` after you authenticate to your registry. + +```yaml +on: push +name: Find LaunchDarkly flag code references +jobs: + launchDarklyCodeReferences: + name: LaunchDarkly Code References + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 11 + - uses: docker/login-action@v3 + with: + registry: your.registry.example + username: ${{ secrets.REGISTRY_USER }} + password: ${{ secrets.REGISTRY_TOKEN }} + - name: LaunchDarkly Code References + # Pin to a release that includes the docker/ entry point (see changelog). + uses: launchdarkly/find-code-references/docker@v2.17.0 + with: + accessToken: ${{ secrets.LD_ACCESS_TOKEN }} + projKey: LD_PROJECT_KEY + dockerImage: your.registry.example/launchdarkly/ld-find-code-refs-github-action:2.17.0 +``` + +Mirror the public image `launchdarkly/ld-find-code-refs-github-action` into your registry (pin `dockerImage` to the scanner image tag you mirrored; it can lag the Action tag). This entry point requires a Docker CLI on the runner (included on GitHub-hosted `ubuntu-*` runners). Existing workflows that use the root Action do not need to change. + ## Additional configuration To customize additional configuration not referenced in [Inputs](#inputs), you may use a configuration file located at `.launchdarkly/coderefs.yml`. The following links provide more inforation about configurable options: @@ -71,7 +104,7 @@ jobs: with: fetch-depth: 11 # This value must be set if the lookback configuration option is not disabled for find-code-references. Read more: https://github.com/launchdarkly/ld-find-code-refs#searching-for-unused-flags-extinctions - name: LaunchDarkly Code References - uses: launchdarkly/find-code-references@v2.16.0 + uses: launchdarkly/find-code-references@v2.17.0 with: accessToken: ${{ secrets.LD_ACCESS_TOKEN }} projKey: LD_PROJECT_KEY diff --git a/docker/action.yml b/docker/action.yml new file mode 100644 index 0000000..419536d --- /dev/null +++ b/docker/action.yml @@ -0,0 +1,129 @@ +name: LaunchDarkly Code References (custom image) +description: >- + Find references to feature flags in your code. Same scanner as the root + Action, but runs using docker run so you can override the image registry + (for example an internal Docker Hub proxy). +author: LaunchDarkly +branding: + icon: toggle-right + color: gray-dark +inputs: + accessToken: + description: "A token with write access to the LaunchDarkly project." + required: true + allowTags: + default: "false" + description: "Enable storing references for tags. Lists the tag as a branch." + required: false + baseUri: + default: "https://app.launchdarkly.com" + description: "The base URL of the LaunchDarkly server for this configuration." + required: false + contextLines: + default: "2" + description: "The number of context lines above and below a code reference for the job to send to LaunchDarkly. By default, the flag finder will not send any context lines to LaunchDarkly. If < 0, it will send no source code to LaunchDarkly. If 0, it will send only the lines containing flag references. If > 0, it will send that number of context lines above and below the flag reference. You may provide a maximum of 5 context lines." + required: false + debug: + default: "false" + description: "Enable verbose debug logging." + required: false + ignoreServiceErrors: + default: "false" + description: "If enabled, the scanner will terminate with exit code 0 when the LaunchDarkly API is unreachable or returns an unexpected response." + required: false + lookback: + default: "10" + description: "Set the number of commits to search in history for whether you removed a feature flag from code. You may set to 0 to disable this feature. Setting this option to a high value will increase search time." + required: false + projKey: + description: "Key of the LaunchDarkly project associated with this repository. Found under Account Settings -> Projects in LaunchDarkly. Cannot be combined with `projects` block in configuration file." + required: false + repoName: + description: "The repository name. Defaults to the current GitHub repository." + required: false + prune: + default: "false" + description: "There is a known issue where the GitHub Action will not prune deleted branch data in private repos. Only enable this if you are running the action in a public repo." + required: false + subdirectory: + description: "The subdirectory to run the action in." + required: false + dockerImage: + description: >- + Container image to run. Defaults to the public Docker Hub image used by + the root Action. Set this to your mirrored/proxy image (for example + your.registry.example/launchdarkly/ld-find-code-refs-github-action:2.17.0). + Authenticate to private registries with docker/login-action (or equivalent) + in a prior step. Requires a runner with a Docker CLI (GitHub-hosted + ubuntu-* runners include one). + required: false + default: "launchdarkly/ld-find-code-refs-github-action:2.17.0" +runs: + using: composite + steps: + - name: Run LaunchDarkly Code References + shell: bash + env: + DOCKER_IMAGE: ${{ inputs.dockerImage }} + LD_PROJ_KEY: ${{ inputs.projKey }} + LD_ACCESS_TOKEN: ${{ inputs.accessToken }} + LD_REPO_NAME: ${{ inputs.repoName }} + LD_BASE_URI: ${{ inputs.baseUri }} + LD_CONTEXT_LINES: ${{ inputs.contextLines }} + LD_ALLOW_TAGS: ${{ inputs.allowTags }} + LD_DEBUG: ${{ inputs.debug }} + LD_IGNORE_SERVICE_ERRORS: ${{ inputs.ignoreServiceErrors }} + LD_LOOKBACK: ${{ inputs.lookback }} + LD_PRUNE: ${{ inputs.prune }} + LD_SUBDIRECTORY: ${{ inputs.subdirectory }} + GITHUB_TOKEN: ${{ github.token }} + run: | + set -euo pipefail + + if [[ -z "${DOCKER_IMAGE:-}" ]]; then + echo "::error::dockerImage input must not be empty" + exit 1 + fi + if [[ -z "${GITHUB_WORKSPACE:-}" || ! -d "${GITHUB_WORKSPACE}" ]]; then + echo "::error::GITHUB_WORKSPACE is missing or not a directory; ensure actions/checkout ran before this step" + exit 1 + fi + if [[ -z "${GITHUB_EVENT_PATH:-}" || ! -f "${GITHUB_EVENT_PATH}" ]]; then + echo "::error::GITHUB_EVENT_PATH is missing or not a readable file" + exit 1 + fi + if ! command -v docker >/dev/null 2>&1; then + echo "::error::docker CLI not found on the runner; this Action entry point requires Docker" + exit 1 + fi + + proxy_env=() + for v in HTTP_PROXY HTTPS_PROXY NO_PROXY http_proxy https_proxy no_proxy; do + if [[ -n "${!v:-}" ]]; then + proxy_env+=(-e "$v") + fi + done + + docker run --rm \ + -v "${GITHUB_WORKSPACE}:${GITHUB_WORKSPACE}" \ + -w "${GITHUB_WORKSPACE}" \ + -v "${GITHUB_EVENT_PATH}:${GITHUB_EVENT_PATH}:ro" \ + -e GITHUB_WORKSPACE \ + -e GITHUB_EVENT_PATH \ + -e GITHUB_REPOSITORY \ + -e GITHUB_REF \ + -e GITHUB_ACTIONS=true \ + -e GITHUB_TOKEN \ + -e LD_PROJ_KEY \ + -e LD_ACCESS_TOKEN \ + -e LD_REPO_NAME \ + -e LD_BASE_URI \ + -e LD_CONTEXT_LINES \ + -e LD_ALLOW_TAGS \ + -e LD_DEBUG \ + -e LD_IGNORE_SERVICE_ERRORS \ + -e LD_LOOKBACK \ + -e LD_PRUNE \ + -e LD_SUBDIRECTORY \ + "${proxy_env[@]}" \ + "${DOCKER_IMAGE}"