Skip to content

Commit 202d370

Browse files
committed
action: improve the README
Signed-off-by: Paul Jolly <paul@myitcv.io> Change-Id: I3d36c157cd3ddc9660a917c678fb619b7ff1aaea
1 parent e8b3bba commit 202d370

1 file changed

Lines changed: 70 additions & 42 deletions

File tree

README.md

Lines changed: 70 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,39 @@
11
# Login to CUE Registry via GitHub OIDC
22

3-
A GitHub Action that authenticates to a CUE registry using GitHub's OIDC tokens.
3+
This GitHub Action authenticates to the [CUE Central
4+
Registry](https://registry.cue.works) (or a self-hosted registry) using GitHub's
5+
OIDC tokens.
6+
7+
By default, it automatically configures the `cue` CLI credentials, allowing
8+
subsequent steps to run `cue mod publish` or other commands without manual
9+
authentication setup.
410

511
## Features
612

7-
- Authenticates using GitHub's OIDC provider (no static credentials needed)
8-
- Optionally, automatically configures `cue` CLI `logins.json` file with
9-
registry credentials
13+
* **Zero-secret authentication:** Uses GitHub OIDC (OpenID Connect) to exchange
14+
a temporary GitHub token for a CUE Registry token. No long-lived secrets are
15+
required.
16+
* **Secure by default:** The generated access token is automatically masked as a
17+
secret in workflow logs to prevent accidental leakage.
18+
* **Automatic CLI configuration:** Updates `~/.config/cue/logins.json` by
19+
default, so the `cue` command works immediately.
20+
* **Flexible:** Can be configured to output a raw access token for use with
21+
`curl` or other API clients.
1022

1123
## Prerequisites
1224

13-
Your CUE Central Registry must be
14-
[configured](https://registry.cue.works/account/oidc) to trust the registry's
15-
OIDC endpoint.
25+
### 1. Configure Registry Trust
26+
27+
Your CUE Central Registry namespace must be configured to trust your GitHub
28+
repository.
29+
30+
* **[Configure CUE Central Registry
31+
OIDC](https://registry.cue.works/account/oidc)**
1632

17-
The workflow job must contain a
18-
[`permissions`](https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#permissions)
19-
entry enabling access to the GitHub OIDC token:
33+
### 2. Workflow Permissions
34+
35+
The workflow job must have permission to request an OIDC token. Add the
36+
following `permissions` block to your job:
2037

2138
```yaml
2239
permissions:
@@ -25,91 +42,102 @@ permissions:
2542
2643
## Usage
2744
28-
### Basic usage
45+
### Basic Usage (CUE Central Registry)
46+
47+
This is the standard pattern. It authenticates with `registry.cue.works` and
48+
sets up the `cue` CLI.
2949

3050
```yaml
3151
- name: Login to CUE registry
3252
uses: cue-labs/registry-login-action@v1
53+
3354
```
3455

35-
Once this is in place, the subsequent steps can use the `cue` CLI commands
36-
logged-in as specified in the CUE Central Registry trust configuration.
56+
### Advanced Usage
3757

38-
### Using the access token
58+
#### Using a Custom Registry
3959

40-
By default no additional steps are needed as the `cue` command is automatically
41-
authenticated after the login step.
60+
If you are using a registry other than the CUE Central Registry:
4261

43-
For other use-cases, the action outputs an `access_token` that can be used as a
44-
bearer token for direct API calls:
62+
```yaml
63+
- name: Login to custom registry
64+
uses: cue-labs/registry-login-action@v1
65+
with:
66+
registry: registry.example.com
67+
68+
```
69+
70+
#### Using the Access Token directly (API Mode)
71+
72+
If you do not want to update the `logins.json` file (for example, to use the
73+
token with `curl`):
4574

4675
```yaml
4776
- name: Login to CUE registry
4877
id: oidc
4978
uses: cue-labs/registry-login-action@v1
79+
with:
80+
update_logins: false
5081
51-
- name: Test registry access
82+
- name: Call Registry API
5283
run: |
5384
curl -sSL https://registry.cue.works/v2/ \
5485
-H "Authorization: Bearer ${{ steps.oidc.outputs.access_token }}"
86+
5587
```
5688

5789
## Inputs
5890

5991
| Input | Description | Required | Default |
60-
|-------|-------------|----------|---------|
61-
| `registry` | CUE registry hostname | No | `registry.cue.works` |
62-
| `update_logins` | Whether to update the local CUE logins.json file | No | `true` |
92+
| --- | --- | --- | --- |
93+
| `registry` | The hostname of the CUE registry. | No | `registry.cue.works` |
94+
| `update_logins` | If `true`, writes credentials to the standard CUE `logins.json` file. | No | `true` |
6395

6496
## Outputs
6597

6698
| Output | Description |
67-
|--------|-------------|
68-
| `access_token` | The access token obtained from the registry |
99+
| --- | --- |
100+
| `access_token` | The short-lived OAuth access token obtained from the registry. **This value is masked as a secret in logs.** |
69101

70-
## How it works
102+
## Complete Workflow Example
71103

72-
1. Obtains a GitHub OIDC token with the registry URL as the audience
73-
2. Exchanges the OIDC token for a registry access token
74-
3. Optionally configures the `cue` CLI with the registry credentials in `~/.config/cue/logins.json`
75-
76-
## Example workflow
104+
This example demonstrates a full release pipeline that publishes a module when a
105+
tag is pushed.
77106

78107
```yaml
79108
name: Publish CUE module
80109
81110
on:
82-
# Example
83111
push:
84-
tags:
85-
- 'v*'
112+
tags: ['v*']
86113
87114
jobs:
88115
publish:
89116
runs-on: ubuntu-latest
90-
91-
# Enable GitHub OIDC token
92117
permissions:
118+
# Required for OIDC authentication
93119
id-token: write
120+
contents: read
94121
95122
steps:
96123
- name: Checkout code
97-
- uses: actions/checkout@v6
124+
uses: actions/checkout@v4
98125
99-
# Log into the registry using OIDC
126+
# Log into the registry (updates ~/.config/cue/logins.json)
100127
- name: Login to CUE registry
101-
id: oidc
102128
uses: cue-labs/registry-login-action@v1
103129
104130
- name: Install Go
105-
uses: actions/setup-go@v6
131+
uses: actions/setup-go@v5
106132
with:
107133
go-version: '1.25'
108134
109-
- name: Install Cue
135+
- name: Install CUE
110136
run: go install cuelang.org/go/cmd/cue@latest
111137
112138
- name: Publish module
113-
run: |
114-
cue mod publish ${{ github.ref_name }}
139+
# The 'cue' command is already authenticated by the login action
140+
run: cue mod publish ${{ github.ref_name }}
141+
115142
```
143+

0 commit comments

Comments
 (0)