Skip to content

Commit

Permalink
Preparing the action for the initial release
Browse files Browse the repository at this point in the history
  • Loading branch information
bwoskow-ld committed Aug 7, 2019
1 parent a788772 commit dab9828
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 8 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
on: push
name: Example Workflow
jobs:
launchDarklyCodeReferences:
name: LaunchDarkly Code References
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: LaunchDarkly Code References
uses: launchdarkly/find-code-references@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
LD_ACCESS_TOKEN: ${{ secrets.LD_ACCESS_TOKEN }}
LD_PROJ_KEY: YOUR_PROJECT_KEY
9 changes: 1 addition & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
FROM alpine:3.8

RUN apk update
RUN apk add --no-cache git
RUN apk add --no-cache the_silver_searcher

COPY ld-find-code-refs-github-action /ld-find-code-refs-github-action
FROM launchdarkly/ld-find-code-refs-github-action:1.1.1

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

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

48 changes: 48 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# LaunchDarkly Code References with GitHub Actions

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.

## Configuration

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".

(For help storing this see the [GitHub docs](https://help.github.com/en/articles/creating-a-github-action).)

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:

```yaml
on: push
name: Example Workflow
jobs:
launchDarklyCodeReferences:
name: LaunchDarkly Code References
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: LaunchDarkly Code References
uses: launchdarkly/find-code-references@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
LD_ACCESS_TOKEN: ${{ secrets.LD_ACCESS_TOKEN }}
LD_PROJ_KEY: YOUR_PROJECT_KEY
```
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.

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.

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.

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.

## Troubleshooting

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.

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.

## Additional Options

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).

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).
23 changes: 23 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: 'LaunchDarkly Code References'
description: 'Find references to feature flags in your code.'
author: 'LaunchDarkly'
branding:
icon: toggle-right
color: gray-dark
inputs:
ld-proj-key:
description: 'Key of the LaunchDarkly project associated with this repository'
default: 'YOUR_PROJECT_KEY'
required: true
ld-access-token:
description: 'Token with write access to LaunchDarkly project'
required: true
github-token:
description: 'Token to access your GitHub repository. This is only needed if the code has not yet been checkout out in a prior step.'
runs:
using: 'docker'
image: 'Dockerfile'
env:
LD_PROJ_KEY: ${{ inputs.ld-proj-key }}
LD_ACCESS_TOKEN: ${{ inputs.ld-access-token }}
GITHUB_TOKEN: ${{ inputs.github-token }}

0 comments on commit dab9828

Please sign in to comment.