Enterprise · Code references
Set up with GitHub Actions
A workflow file, two secrets and one variable make every push to the default branch update the flag's code references.
Video coming soon
Set up with GitHub Actions
Before you start
- A system client token with the scopes Code references write and Evaluate (Overview).
- Admin rights on the GitHub repository, to add secrets and variables.
Add the workflow
- Download
fluxgate-code-refs.github.yml. - Save it in your repository as
.github/workflows/fluxgate-code-refs.yml. - If your default branch is not
main, changebranches: [main]to its name. - In GitHub, open Settings, Secrets and variables, Actions. On Secrets, add
FLUXGATE_URL(your API URL, such ashttps://flags.example.com/api/v1) andFLUXGATE_TOKEN(the system client token). - On Variables, add
FLUXGATE_VERSION: the FluxGate release whose CLI the job downloads, such asv2.0.1. The job downloads it fromhttps://flux.forgeopslabs.com/downloads/releases/<version>/. - Commit the workflow to the default branch. The run FluxGate code references starts.
The job downloads the CLI archive for the runner, checks it against SHA256SUMS from the same release, and runs:
fluxgate code-refs scan --context-lines 1 --default-branch <default branch>Deleted branches
The workflow also runs when a branch is deleted. Its prune job runs:
fluxgate code-refs prune --branch <deleted branch>It deletes the stored scan of that branch. It never deletes the default branch, and a branch that was never scanned is skipped. A daily job on the backend also deletes branch scans that got no upload for 30 days.
Scan more branches
The workflow scans pushes to the default branch. To keep references of other long-lived branches, such as a release branch, add them to branches:
on:
push:
branches: [main, release]Removal issues
The workflow can also open one issue per flag whose code should be removed. See Open removal issues.
Optional variables
| Variable | Meaning |
|---|---|
FLUXGATE_DOWNLOAD_BASE | Download the CLI and SHA256SUMS from here instead of https://flux.forgeopslabs.com/downloads/releases/<version>, for example a mirror inside your network |
FLUXGATE_CONTEXT_LINES | Lines sent above and below each match, 0 to 5. Default 1. Use 0 to send no code |
FLUXGATE_SCAN_ARGS | Extra scan arguments, separated by spaces and written without quotes, for example --exclude generated/** |
Check the result
Open the job log. The last step prints the server's answer with refCount and unknownKeys: keys found in the code that name no flag of the team. Then open a flag in FluxGate: the Code references card lists the files and lines.