Skip to content

Commit

Permalink
Add input for GitHub API URL
Browse files Browse the repository at this point in the history
Add an option to override the GitHub API URL to use - defaults to `$GITHUB_API_URL`.
  • Loading branch information
martincostello committed May 30, 2024
1 parent b44ceb1 commit fa20707
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ inputs:
github-pat:
description: 'GitHub Personal Access Token (PAT) for submitting SBOM to GitHub Dependency Snapshot API'
required: false
github-api-url:
description: 'URL of the GitHub REST API for submitting SBOM to GitHub Dependency Snapshot API'
required: false
default: ${{ github.api_url }}
trivy-config:
description: 'path to trivy.yaml config'
required: false
Expand Down Expand Up @@ -124,6 +128,7 @@ runs:
- '-t ${{ inputs.trivyignores }}'
- '-u ${{ inputs.github-pat }}'
- '-v ${{ inputs.trivy-config }}'
- '-w ${{ inputs.github-api-url }}'
- '-x ${{ inputs.tf-vars }}'
- '-z ${{ inputs.limit-severities-for-sarif }}'
- '-y ${{ inputs.docker-host }}'
7 changes: 5 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
set -e
while getopts "a:b:c:d:e:f:g:h:i:j:k:l:m:n:o:p:q:r:s:t:u:v:x:y:z:" o; do
while getopts "a:b:c:d:e:f:g:h:i:j:k:l:m:n:o:p:q:r:s:t:u:v:w:x:y:z:" o; do
case "${o}" in
a)
export scanType=${OPTARG}
Expand Down Expand Up @@ -68,6 +68,9 @@ while getopts "a:b:c:d:e:f:g:h:i:j:k:l:m:n:o:p:q:r:s:t:u:v:x:y:z:" o; do
v)
export trivyConfig=${OPTARG}
;;
w)
export githubApiUrl=${OPTARG}
;;
x)
export tfVars=${OPTARG}
;;
Expand Down Expand Up @@ -207,7 +210,7 @@ set -e
if [[ "${format}" == "github" ]]; then
if [[ "$(echo $githubPAT | xargs)" != "" ]]; then
printf "\n Uploading GitHub Dependency Snapshot"
curl -H 'Accept: application/vnd.github+json' -H "Authorization: token $githubPAT" ''$GITHUB_API_URL'/repos/'$GITHUB_REPOSITORY'/dependency-graph/snapshots' -d @./$(echo $output | xargs)
curl -H 'Accept: application/vnd.github+json' -H "Authorization: token $githubPAT" ''$githubApiUrl'/repos/'$GITHUB_REPOSITORY'/dependency-graph/snapshots' -d @./$(echo $output | xargs)
else
printf "\n Failing GitHub Dependency Snapshot. Missing github-pat"
fi
Expand Down

0 comments on commit fa20707

Please sign in to comment.