Skip to content

Commit

Permalink
Merge pull request #62 from jitsecurity-controls/sc-23590-jit-github-…
Browse files Browse the repository at this point in the history
…action-retry-every-error-when

Update retry-curl.sh
  • Loading branch information
avichayJit committed Feb 21, 2024
2 parents c2803f0 + 970f305 commit 60aee2e
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,31 @@ runs:
ref: main
path: ./.github/actions/jit-github-action

- name: Install OIDC Client from Core Package
shell: bash
run: npm install @actions/core@1.6.0 @actions/http-client

- name: Get OIDC Token
uses: actions/github-script@v6
id: get-oidc-token-from-github
with:
script: |
const actionCore = require('@actions/core')
const { execSync } = require('child_process');
try {
const OIDC_TOKEN = await actionCore.getIDToken()
actionCore.setOutput('OIDC_TOKEN', OIDC_TOKEN)
} catch (error) {
actionCore.error('Failed to get OIDC Token from github servers: ' + error)
execSync('exit 100');
}
- id: oidc-auth
shell: bash
env:
OIDC_TOKEN: ${{ steps.get-oidc-token-from-github.outputs.OIDC_TOKEN }}
run: |
source ./.github/actions/jit-github-action/retry-curl.sh
OIDC_TOKEN_RESPONSE=$(retry_curl -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" "$ACTIONS_ID_TOKEN_REQUEST_URL")
OIDC_TOKEN_RESPONSE_CODE=${OIDC_TOKEN_RESPONSE: -3}
echo "Calling Github OIDC Auth endpoint returned with response_code=$OIDC_TOKEN_RESPONSE_CODE"
if [ $OIDC_TOKEN_RESPONSE_CODE = 200 ]; then
OIDC_TOKEN_RESPONSE_BODY=${OIDC_TOKEN_RESPONSE:0:${#OIDC_TOKEN_RESPONSE}-3}
OIDC_TOKEN=$(echo $OIDC_TOKEN_RESPONSE_BODY | jq -r '.value')
else
echo "Got fatal error when calling github oidc"
exit 100
fi
source ./.github/actions/jit-github-action/retry-curl.sh
AUTH_RESPONSE=$(retry_curl \
-X POST \
-H "Authorization: Bearer $OIDC_TOKEN" \
Expand Down

0 comments on commit 60aee2e

Please sign in to comment.