Skip to content

Commit b133760

Browse files
committed
chore(ci): print the CI app identity (throwaway)
1 parent 4e48de8 commit b133760

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: identify-ci-app
2+
3+
on:
4+
push:
5+
branches: [chore/identify-ci-app]
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
whoami:
12+
name: 🔎 Identify the CI app
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Print the CI app identity
16+
env:
17+
STREAM_KEY: ${{ secrets.STREAM_KEY }}
18+
STREAM_SECRET: ${{ secrets.STREAM_SECRET }}
19+
run: |
20+
token=$(python3 -c '
21+
import base64, hashlib, hmac, json, os
22+
b = lambda r: base64.urlsafe_b64encode(r).rstrip(b"=")
23+
s = os.environ["STREAM_SECRET"].encode()
24+
i = b(json.dumps({"alg":"HS256","typ":"JWT"},separators=(",",":")).encode()) + b"." + b(json.dumps({"server":True},separators=(",",":")).encode())
25+
print((i + b"." + b(hmac.new(s, i, hashlib.sha256).digest())).decode())')
26+
curl -sS -H "Authorization: $token" -H "stream-auth-type: jwt" \
27+
"https://chat.stream-io-api.com/app?api_key=$STREAM_KEY" \
28+
| python3 -c 'import json,sys; a=json.load(sys.stdin)["app"]; print("app:", a["name"], "| org:", a.get("organization"))'

0 commit comments

Comments
 (0)