Skip to content

Commit

Permalink
Update test CICD with env variables to fetch bearer token
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Wenger committed Feb 21, 2024
1 parent 6bdc41a commit c11d5c8
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 39 deletions.
60 changes: 35 additions & 25 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,45 @@ name: PHP Composer

on:
push:
branches: [ main ]
branches: [main]
pull_request:
branches: [ main ]
branches: [main]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Update Composer.json
run: composer update

- name: Validate composer.json and composer.lock
run: composer validate --strict

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v2
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install dependencies
run: composer install --prefer-dist --no-progress

- name: Run test suite
run: USERNAME="${{ secrets.API_USERNAME }}" PASSWORD="${{ secrets.API_PASSWORD }}" composer run-script test
- uses: actions/checkout@v2

- name: Update Composer.json
run: composer update

- name: Validate composer.json and composer.lock
run: composer validate --strict

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v2
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- 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: Install dependencies
run: composer install --prefer-dist --no-progress

- name: Run test suite
run: composer run-script test
env:
BEARER_TOKEN: ${{ env.BEARER_TOKEN }}
14 changes: 0 additions & 14 deletions .whitesource

This file was deleted.

0 comments on commit c11d5c8

Please sign in to comment.