File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -17,14 +17,14 @@ action:
1717 command -v gh && exit 0
1818 curl -sL https://github.com/cli/cli/releases/latest/download/gh_2.74.0_linux_amd64.tar.gz | tar xz -C /tmp
1919 sudo mv /tmp/gh_2.74.0_linux_amd64/bin/gh /usr/local/bin/gh
20- # Step 2: Authenticate gh using the git credential helper
20+ # Step 2: Export GITHUB_TOKEN from git credential helper
2121 - task :
2222 command : |
23- printf 'protocol=https\nhost=github.com\n\n' | git credential fill | awk -F= '/password/{print $2}' | gh auth login --with -token
23+ printf 'protocol=https\nhost=github.com\n\n' | git credential fill | awk -F= '/password/{print $2}' > /tmp/.gh -token
2424 # Step 3: Fetch the highest-severity open code scanning alert
2525 - task :
2626 command : |
27- gh api repos/{owner}/{repo}/code-scanning/alerts \
27+ GITHUB_TOKEN=$(cat /tmp/.gh-token) gh api repos/{owner}/{repo}/code-scanning/alerts \
2828 --jq '[.[] | select(.state=="open")] | sort_by(.rule.security_severity_level // "low") | reverse | .[0]' \
2929 > /tmp/codescan-alert.json
3030 cat /tmp/codescan-alert.json
Original file line number Diff line number Diff line change @@ -17,14 +17,14 @@ action:
1717 command -v gh && exit 0
1818 curl -sL https://github.com/cli/cli/releases/latest/download/gh_2.74.0_linux_amd64.tar.gz | tar xz -C /tmp
1919 sudo mv /tmp/gh_2.74.0_linux_amd64/bin/gh /usr/local/bin/gh
20- # Step 2: Authenticate gh using the git credential helper
20+ # Step 2: Export GITHUB_TOKEN from git credential helper
2121 - task :
2222 command : |
23- printf 'protocol=https\nhost=github.com\n\n' | git credential fill | awk -F= '/password/{print $2}' | gh auth login --with -token
23+ printf 'protocol=https\nhost=github.com\n\n' | git credential fill | awk -F= '/password/{print $2}' > /tmp/.gh -token
2424 # Step 3: Fetch the highest-severity open Dependabot alert
2525 - task :
2626 command : |
27- gh api repos/{owner}/{repo}/dependabot/alerts \
27+ GITHUB_TOKEN=$(cat /tmp/.gh-token) gh api repos/{owner}/{repo}/dependabot/alerts \
2828 --jq '[.[] | select(.state=="open")] | sort_by(.security_advisory.cvss.score) | reverse | .[0]' \
2929 > /tmp/dependabot-alert.json
3030 cat /tmp/dependabot-alert.json
You can’t perform that action at this time.
0 commit comments