Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
504865e
feat: install the CLI and exchange the job's OIDC token
khvn26 Aug 18, 2026
5946040
refactor: delegate installation to the CLI's own installers
khvn26 Aug 18, 2026
4864241
refactor: drop the action's outputs
khvn26 Aug 18, 2026
ca672a5
refactor: collapse the platform branches and drop the unread token type
khvn26 Aug 18, 2026
f6bee56
refactor: stop pre-checking for curl and wget
khvn26 Aug 18, 2026
236cb00
refactor: look failure hints up in a table
khvn26 Aug 18, 2026
85d7cbc
refactor: inline the version helpers into resolveVersion
khvn26 Aug 18, 2026
1275a2d
test: read a real event file instead of injecting a reader
khvn26 Aug 18, 2026
d0db1b8
refactor: order each module public-first and high-level-first
khvn26 Aug 18, 2026
b724eb0
fix: show the error body whatever its content type
khvn26 Aug 18, 2026
f409361
refactor: find the folded credential name in one expression
khvn26 Aug 18, 2026
1be14d4
style: drop a blank line from an import list
khvn26 Aug 18, 2026
5b8aebd
refactor: inline the api-url normalisation into its only caller
khvn26 Aug 18, 2026
3afe754
refactor: normalise api-url with the URL parser
khvn26 Aug 18, 2026
e9123ad
refactor: read GITHUB_TOKEN where it is used
khvn26 Aug 18, 2026
2b14fa1
refactor: one error for a release response we cannot read
khvn26 Aug 18, 2026
9f75a39
fix: show the release response body when it cannot be read
khvn26 Aug 18, 2026
656147b
refactor: let the installer choose the latest release
khvn26 Aug 18, 2026
aa07fd1
feat: resolve an unpinned version with the installer's dry run
khvn26 Aug 18, 2026
4b1588f
fix: degrade to an uncached install when the dry run says nothing
khvn26 Aug 18, 2026
7195aac
refactor: inline the dry-run parse into installCli
khvn26 Aug 18, 2026
570516f
feat: fall back to the installed binary for the cache key
khvn26 Aug 18, 2026
a48eb3b
refactor: take the version straight from the binary's output
khvn26 Aug 18, 2026
fe69ab5
refactor: one truthiness test for the resolved version
khvn26 Aug 18, 2026
2396f60
refactor: name the installer scripts with a literal union
khvn26 Aug 18, 2026
93c6ead
refactor: split the entrypoint from the action logic
khvn26 Aug 18, 2026
b3eaa99
refactor: one throw for a response that is not a 200
khvn26 Aug 18, 2026
fd43813
improve docs
khvn26 Aug 18, 2026
dd357b9
chore: pre-commit, security-only renovate, release-please, PR tests
khvn26 Aug 18, 2026
01ce478
chore: pin workflow actions to commit SHAs
khvn26 Aug 18, 2026
b501213
chore: drop the CI test workflow
khvn26 Aug 18, 2026
e0f39f3
fix: name the version that ships the exchange endpoint
khvn26 Aug 18, 2026
229ecac
improve docs
khvn26 Aug 18, 2026
610d53c
chore: empty commit to trigger CI
khvn26 Aug 18, 2026
41ea715
chore: skip the npm hooks on pre-commit.ci
khvn26 Aug 18, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Pull request

on: pull_request

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: 24
cache: npm
- run: npm ci
- run: npx vitest run
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
lib/
*.tsbuildinfo
26 changes: 26 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# These hooks need the repo's npm toolchain, which pre-commit.ci's image does
# not carry. They run locally; PRs get vitest from pull-request.yml.
ci:
skip: [typecheck, test, dist]

repos:
- repo: local
hooks:
- id: typecheck
name: tsc --noEmit
entry: npm run typecheck
language: system
files: \.(ts|json)$
pass_filenames: false
- id: test
name: vitest
entry: npx vitest run
language: system
files: \.ts$
pass_filenames: false
- id: dist
name: dist matches src
entry: sh -c 'npm run build >/dev/null 2>&1 && git diff --exit-code dist'
language: system
files: ^(src/|package\.json|tsconfig\.json)
pass_filenames: false
3 changes: 3 additions & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
".": "1.0.0"
}
57 changes: 55 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,55 @@
# setup-cli
鈻讹笍 GitHub Action to download and install the Flagsmith CLI
# `Flagsmith/setup-cli`

Install the [Flagsmith CLI](https://github.com/Flagsmith/flagsmith-cli) in a GitHub Actions job, and authenticate it without storing a secret.

## Usage

```yaml
jobs:
flagsmith:
runs-on: ubuntu-latest
permissions:
id-token: write # required for the token exchange
contents: read
steps:
- uses: Flagsmith/setup-cli@v1
- run: flagsmith auth status
```

## Inputs

| Input | Default | Description |
| ------------- | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `api-url` | `https://api.flagsmith.com` | Flagsmith API base URL. Set this for self-hosted instances. |
| `audience` | GitHub's default | The `aud` claim to request. GitHub's default is `https://github.com/OWNER`, which is what the GitHub Actions trust relationship form expects. Set it to target a specific `audience`. |
| `cli-version` | `latest` | CLI version to install, e.g. `v2.0.0`. |

## When the action skips authentication

The CLI is always installed. Authentication is skipped, with a warning, when:

- the job has no `id-token: write` permission.
- the run is a pull request from a fork.
- the job already carries a credential the CLI would use for this `api-url` (`FLAGSMITH_API_KEY` or `FLAGSMITH_ACCESS_TOKEN`, scoped to provided `api-url`). Bring your own key and the action leaves it alone:

```yaml
- uses: Flagsmith/setup-cli@v1
- run: flagsmith auth status
env:
FLAGSMITH_API_KEY: ${{ secrets.FLAGSMITH_API_KEY }}
```

## What the action exports

- `FLAGSMITH_API_URL` so later steps talk to the same instance.
- `FLAGSMITH_ACCESS_TOKEN_<HOST>` the access token, scoped to the API URL host.

The CLI binary is added to `PATH` via `GITHUB_PATH`, and cached in the runner tool cache by version and architecture.

## Development

```sh
npm ci
npm test # unit tests
npm run all # typecheck, test, and rebuild dist/
```
32 changes: 32 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Setup Flagsmith CLI
description: >-
Install the Flagsmith CLI and, when the job has an OIDC identity, exchange it
for a short-lived Flagsmith access token.
author: Flagsmith

branding:
icon: flag
color: purple

inputs:
api-url:
description: Flagsmith API base URL.
required: false
default: https://api.flagsmith.com
audience:
description: >-
The `aud` claim to request for the GitHub OIDC token. Leave unset to use
GitHub's default audience (https://github.com/OWNER). Set it to target a trust
relationship configured with a specific audience.
required: false
default: ""
cli-version:
description: >-
Version of the CLI to install, e.g. `v2.0.0`. Defaults to the latest
release.
required: false
default: latest

runs:
using: node24
main: dist/index.cjs
Loading