-
Notifications
You must be signed in to change notification settings - Fork 43
feat: optional GitHub Action dockerImage entry point #611
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tknopp-ld
wants to merge
2
commits into
main
Choose a base branch
from
feat/docker-image-override
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| name: LaunchDarkly Code References (custom image) | ||
| description: >- | ||
| Find references to feature flags in your code. Same scanner as the root | ||
| Action, but runs via 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.16.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.16.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 | ||
|
|
||
| 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 \ | ||
| "${DOCKER_IMAGE}" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.