Skip to content

Commit dab9828

Browse files
committed
Preparing the action for the initial release
1 parent a788772 commit dab9828

File tree

4 files changed

+86
-8
lines changed

4 files changed

+86
-8
lines changed

.github/workflows/action.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
on: push
2+
name: Example Workflow
3+
jobs:
4+
launchDarklyCodeReferences:
5+
name: LaunchDarkly Code References
6+
runs-on: ubuntu-latest
7+
steps:
8+
- uses: actions/checkout@master
9+
- name: LaunchDarkly Code References
10+
uses: launchdarkly/find-code-references@master
11+
env:
12+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
13+
LD_ACCESS_TOKEN: ${{ secrets.LD_ACCESS_TOKEN }}
14+
LD_PROJ_KEY: YOUR_PROJECT_KEY

Dockerfile

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
FROM alpine:3.8
2-
3-
RUN apk update
4-
RUN apk add --no-cache git
5-
RUN apk add --no-cache the_silver_searcher
6-
7-
COPY ld-find-code-refs-github-action /ld-find-code-refs-github-action
1+
FROM launchdarkly/ld-find-code-refs-github-action:1.1.1
82

93
LABEL com.github.actions.name="LaunchDarkly Code References"
104
LABEL com.github.actions.description="Find references to feature flags in your code."
@@ -13,4 +7,3 @@ LABEL com.github.actions.color="gray-dark"
137
LABEL homepage="https://www.launchdarkly.com"
148

159
ENTRYPOINT ["/ld-find-code-refs-github-action"]
16-

README.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# LaunchDarkly Code References with GitHub Actions
2+
3+
This GitHub Action is a utility that automatically populates code references in LaunchDarkly. This is useful for finding references to feature flags in your code, both for reference and for code cleanup.
4+
5+
## Configuration
6+
7+
Once you've [created a LaunchDarkly access token](https://docs.launchdarkly.com/docs/git-code-references#section-creating-an-access-token), store the newly created access token as a repository secret titled `LD_ACCESS_TOKEN`. Under Settings > Secrets in your GitHub repo, you'll see a link to "Add a new secret". Click that and paste in your access token and click "Save secret".
8+
9+
(For help storing this see the [GitHub docs](https://help.github.com/en/articles/creating-a-github-action).)
10+
11+
Next, create a new Actions workflow in your selected GitHub repository. If you don't already have a workflow file, you'll need to create a new file titled `action.yml` in the `.github/workflows` directory of your repository. Under "Edit new file", paste the following code:
12+
13+
```yaml
14+
on: push
15+
name: Example Workflow
16+
jobs:
17+
launchDarklyCodeReferences:
18+
name: LaunchDarkly Code References
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v1
22+
- name: LaunchDarkly Code References
23+
uses: launchdarkly/find-code-references@v1
24+
env:
25+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26+
LD_ACCESS_TOKEN: ${{ secrets.LD_ACCESS_TOKEN }}
27+
LD_PROJ_KEY: YOUR_PROJECT_KEY
28+
```
29+
30+
We strongly recommend that you update the second `uses` attribute value to reference the latest tag in the [launchdarkly/find-code-references repository](https://github.com/launchdarkly/find-code-references). This will pin your workflow to a particular version of the `launchdarkly/find-code-references` action.
31+
32+
If you already have a `action.yml` file, copy and paste the above `launchDarklyCodeReferences` job declaration into the `jobs` section in your existing `action.yml` file. If you wish to verify that you've pasted the above correctly, you can go into the visual editor and ensure that there are no syntax errors. `LD_PROJ_KEY` refers to the key of the LaunchDarkly project associated with this repository.
33+
34+
Commit this file under a new branch. Submit as a PR to your code reviewers to be merged into your master branch. You do not need to have this branch merged into the master for code references to appear in the LaunchDarkly UI for your flags; code references will appear for this newly created branch.
35+
36+
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.
37+
38+
## Troubleshooting
39+
40+
Once your workflow has been created, the best way to confirm that the workflow is executing correctly is to create a new pull request with the workflow file and verify that the newly created action succeeds.
41+
42+
If the action fails, there may be a problem with your configuration. To investigate, dig into the action's logs to view any error messages.
43+
44+
## Additional Options
45+
46+
Additional configuration options for more environmental variables can be found at the bottom of the [LaunchDarkly GitHub Action documentation](https://docs.launchdarkly.com/docs/github-actions#section-additional-configuration-options).
47+
48+
For information about the underlying LaunchDarkly Code References command-line tool, take a look at [this repository](https://github.com/launchdarkly/ld-find-code-refs).

action.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: 'LaunchDarkly Code References'
2+
description: 'Find references to feature flags in your code.'
3+
author: 'LaunchDarkly'
4+
branding:
5+
icon: toggle-right
6+
color: gray-dark
7+
inputs:
8+
ld-proj-key:
9+
description: 'Key of the LaunchDarkly project associated with this repository'
10+
default: 'YOUR_PROJECT_KEY'
11+
required: true
12+
ld-access-token:
13+
description: 'Token with write access to LaunchDarkly project'
14+
required: true
15+
github-token:
16+
description: 'Token to access your GitHub repository. This is only needed if the code has not yet been checkout out in a prior step.'
17+
runs:
18+
using: 'docker'
19+
image: 'Dockerfile'
20+
env:
21+
LD_PROJ_KEY: ${{ inputs.ld-proj-key }}
22+
LD_ACCESS_TOKEN: ${{ inputs.ld-access-token }}
23+
GITHUB_TOKEN: ${{ inputs.github-token }}

0 commit comments

Comments
 (0)