Skip to content

Commit db49bb5

Browse files
authored
feat: Add action for logging into spice management endpoint (#10)
* feat: Add spice management token login * fix * fix
1 parent 0b67f11 commit db49bb5

2 files changed

Lines changed: 55 additions & 0 deletions

File tree

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: "Management Login"
2+
description: "Fetches a Spice OAuth access token and exports it as an env var for remaining steps."
3+
4+
inputs:
5+
client-id:
6+
description: "OAuth client id"
7+
required: true
8+
client-secret:
9+
description: "OAuth client secret"
10+
required: true
11+
token-url:
12+
description: "OAuth token endpoint"
13+
required: false
14+
default: "https://dev.spice.ai/api/oauth/token"
15+
env-name:
16+
description: "Environment variable name to set"
17+
required: false
18+
default: "SPICE_MANAGEMENT_TOKEN"
19+
20+
outputs:
21+
token:
22+
description: "Extracted access token from response"
23+
value: ${{ steps.token.outputs.value }}
24+
25+
runs:
26+
using: "composite"
27+
steps:
28+
- name: Request OAuth token
29+
id: token
30+
shell: bash
31+
run: |
32+
set -euo pipefail
33+
34+
if ! command -v jq >/dev/null 2>&1; then
35+
echo "jq is required but not found on PATH" >&2
36+
exit 1
37+
fi
38+
39+
response=$(curl -sS -X POST "${{ inputs.token-url }}" -H "Content-Type: application/json" \
40+
-d "$(jq -cn --arg client_id '${{ inputs.client-id }}' --arg client_secret '${{ inputs.client-secret }}' '{client_id: $client_id, client_secret: $client_secret, grant_type: "client_credentials"}')")
41+
42+
value=$(echo "$response" | jq -er '.access_token')
43+
44+
{
45+
echo "${{ inputs.env-name }}=$value"
46+
} >> "$GITHUB_ENV"
47+
48+
{
49+
echo "value=$value"
50+
} >> "$GITHUB_OUTPUT"

.github/workflows/run_spicebench.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ jobs:
1111
steps:
1212
- uses: actions/checkout@v6
1313

14+
- uses: ./.github/actions/management-login
15+
with:
16+
client-id: ${{ secrets.SPICE_MANAGEMENT_CLIENT_ID }}
17+
client-secret: ${{ secrets.SPICE_MANAGEMENT_CLIENT_SECRET }}
18+
1419
- name: Setup Rust toolchain
1520
uses: actions-rust-lang/setup-rust-toolchain@v1
1621
with:

0 commit comments

Comments
 (0)