Skip to content

Commit

Permalink
test: add check token job
Browse files Browse the repository at this point in the history
  • Loading branch information
GraceRuan committed Nov 13, 2024
1 parent 8f22e0a commit d59a711
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/build-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,18 @@ env:
SERVICE_NAME: java-maven-pipeline-example

jobs:
check_token_expiration:
runs-on: ubuntu-latest
steps:
- name: Checkout token expiration
shell: bash
env:
BROKER_JWT: ${{ secrets.<%= brokerJwt %> }}
run: ./.github/workflows/check-token.sh
build-release:
name: Build and release
runs-on: ubuntu-latest
needs: check_token_expiration
permissions:
contents: read
packages: write
Expand Down
17 changes: 17 additions & 0 deletions .github/workflows/check-token.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

RESPONSE_CODE=$(curl -o /dev/null -s -w "%{http_code}" -X 'GET' \
https://broker.io.nrs.gov.bc.ca/v1/health/token-check \
-H 'accept: */*' \
-H 'Authorization: Bearer '"$BROKER_JWT"'' \
)

if [ "$RESPONSE_CODE" -eq 401 ]; then
echo "Unauthorized (401)"
exit 1
elif [ "$RESPONSE_CODE" -eq 403 ]; then
echo "Invalid JWT: Block list has match"
exit 1
else
echo "Response code: $RESPONSE_CODE"
fi

0 comments on commit d59a711

Please sign in to comment.