-
Notifications
You must be signed in to change notification settings - Fork 0
42 lines (35 loc) · 1.2 KB
/
test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
jobs:
test-package:
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v3
- name: Use Node.js 20
uses: actions/setup-node@v3
with:
node-version: 20
- name: Install dependencies
run: npm ci --loglevel=silly
# Step to retrieve the bearer token
- name: Retrieve bearer token
id: get_bearer_token
run: |
response=$(curl -X POST ${{secrets.OKTA_ACCESS_TOKEN_URL}}/connect/token \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=client_credentials&client_id=${{secrets.OKTA_CLIENT_ID}}&client_secret=${{secrets.OKTA_CLIENT_SECRET}}")
token=$(echo $response | jq -r '.access_token')
echo "BEARER_TOKEN=${token}" >> $GITHUB_ENV
- name: Build
run: npm run build
# Use the bearer token as an environment variable in the npm test command
- name: Run npm test with bearer token
run: npm test
env:
BEARER_TOKEN: ${{ env.BEARER_TOKEN }}