-
Notifications
You must be signed in to change notification settings - Fork 469
docs: add GitHub Actions Code References integration documentation #6600
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
Closed
+123
−0
Closed
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
ca504fc
docs: add GitHub Actions Code References integration documentation
TyroneOrrego b876809
Merge branch 'Flagsmith:main' into codereferences
TyroneOrrego e4d78ec
fix(docs): update GitHub Actions Code References documentation for ac…
TyroneOrrego 3ff6c23
Merge branch 'codereferences' of https://github.com/writechoiceorg/fl…
TyroneOrrego 53a2733
fix(docs): enhance clarity and accuracy in GitHub Actions Code Refere…
TyroneOrrego c46e9f0
docs: refine GitHub Actions Code References documentation for improve…
TyroneOrrego 4cb503d
docs: add comprehensive Code and References documentation for GitHub …
TyroneOrrego b45cd67
Apply suggestions from code review
TyroneOrrego 81f16e2
docs: adapted the different feedback recieved about Code Reference.
TyroneOrrego a5fd054
docs: update Code References documentation to reflect changes in GitH…
TyroneOrrego 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,123 @@ | ||
| --- | ||
| title: Code References | ||
| sidebar_label: Code References | ||
| sidebar_position: 30 | ||
| --- | ||
|
|
||
| # Code References | ||
|
|
||
| Flagsmith Code References provide visibility into where feature flags are evaluated in your codebase. By linking your source code metadata to the Flagsmith dashboard, you can identify stale flags, simplify audits, and safely manage technical debt. | ||
|
|
||
|
|
||
|  | ||
|
|
||
|
|
||
|  | ||
|
|
||
| ## How it Works | ||
|
|
||
| Code References are populated by a scanning tool that identifies flag evaluations within your repository. | ||
|
|
||
| 1. **CI code scan**: The CI runner searches your repository (`git ls-files`) for feature flag evaluations. | ||
| 2. **Code references upload**: file path and line number for each evaluation is sent to your Flagsmith project. | ||
| 3. **Visualisation**: Code references are displayed in Features list, and expanded in Feature detail — look for the "Code References" tab. | ||
|
|
||
| :::important Security and Privacy | ||
| **Your source code never leaves your CI runner.** Flagsmith does not receive, store, or have access to your source code. Only file paths and line numbers are transmitted to map code references to your dashboard. | ||
| ::: | ||
|
|
||
| # Set up Code References | ||
|
|
||
| Code References currently integrates with GitHub, with support for other version control providers planned for future releases. | ||
|
|
||
| ## GitHub | ||
|
|
||
| To authorize the scan, you must first configure your project credentials within your GitHub repository settings under **Settings > Secrets and variables > Actions**. | ||
|
|
||
| * **`FLAGSMITH_CODE_REFERENCES_API_KEY` (Secret)**: Generate an Admin API Key in your Flagsmith dashboard under **Organisation Settings > API Keys**. | ||
| * **`FLAGSMITH_PROJECT_ID` (Variable)**: This is the integer ID of your project, found in the browser URL when viewing your project: `app.flagsmith.com/project/{ID}/`. | ||
|
|
||
| ### 1. Simple configuration (Reusable Workflow) | ||
|
|
||
| The quickest way to get started is using the Flagsmith reusable workflow. This handles the identification and synchronization of references automatically. | ||
|
|
||
| :::note | ||
| Note the use of `fromJSON` for the Project ID; GitHub Actions variables are stored as strings, but the Flagsmith API requires an integer. | ||
| ::: | ||
|
|
||
| ```yaml | ||
| # .github/workflows/flagsmith-code-references.yml | ||
| name: Flagsmith Code References | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| collect-code-references: | ||
| name: Collect | ||
| uses: Flagsmith/ci/.github/workflows/collect-code-references.yml@main | ||
| with: | ||
| flagsmith_project_id: ${{ fromJSON(vars.FLAGSMITH_PROJECT_ID) }} | ||
| secrets: | ||
| flagsmith_admin_api_key: ${{ secrets.FLAGSMITH_CODE_REFERENCES_API_KEY }} | ||
|
|
||
| ``` | ||
|
|
||
| ### 2. Advanced configuration (Individual Actions) | ||
|
|
||
| For environments requiring custom logic or specific runner configurations, you can use the discrete actions that compose the workflow. | ||
| ```yaml | ||
| # .github/workflows/flagsmith-code-references.yml | ||
| name: Flagsmith Code References | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| collect-code-references: | ||
| name: Collect code references | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| env: | ||
| FLAGSMITH_API_URL: https://api.flagsmith.com | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Fetch feature names | ||
| id: fetch-feature-names | ||
| uses: Flagsmith/ci/.github/actions/fetch-feature-names@main | ||
| with: | ||
| flagsmith_project_id: ${{ vars.FLAGSMITH_PROJECT_ID }} | ||
| flagsmith_admin_api_url: ${{ env.FLAGSMITH_API_URL }} | ||
| flagsmith_admin_api_key: ${{ secrets.FLAGSMITH_CODE_REFERENCES_API_KEY }} | ||
|
|
||
| - name: Scan code references | ||
| id: scan-code-references | ||
| uses: Flagsmith/ci/.github/actions/scan-code-references@main | ||
| with: | ||
| feature_names: ${{ steps.fetch-feature-names.outputs.feature_names }} | ||
|
|
||
| - name: Upload code references | ||
| uses: Flagsmith/ci/.github/actions/upload-code-references@main | ||
| with: | ||
| code_references: ${{ steps.scan-code-references.outputs.code_references }} | ||
| flagsmith_project_id: ${{ vars.FLAGSMITH_PROJECT_ID }} | ||
| flagsmith_admin_api_url: ${{ env.FLAGSMITH_API_URL }} | ||
| flagsmith_admin_api_key: ${{ secrets.FLAGSMITH_CODE_REFERENCES_API_KEY }} | ||
| repository_url: ${{ github.server_url }}/${{ github.repository }} | ||
| revision: ${{ github.sha }} | ||
|
|
||
|
|
||
| ``` | ||
| ## Related Documentation | ||
|
|
||
| - [Flagsmith Admin API](/integrating-with-flagsmith/flagsmith-api-overview/admin-api): Learn more about the Admin API used by this integration. | ||
| - [GitHub Actions Documentation](https://docs.github.com/en/actions): Official GitHub Actions documentation for workflow configuration. | ||
TyroneOrrego marked this conversation as resolved.
Show resolved
Hide resolved
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This image contains reference to the test repository we created during our meeting earlier today. Please, as we discussed separately, ensure it is redacted. Feel free to tweak numbers in the image to match whichever data is good to display. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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.
Uh oh!
There was an error while loading. Please reload this page.