6161 id : cache_key
6262 shell : bash
6363 run : |
64- echo "cache_key=$(printf 'cached_findings -%s-%s.json' "${{ github.ref_name }}" "${{ matrix.site }}" | tr -cs 'A-Za-z0-9._-' '_')" >> $GITHUB_OUTPUT
64+ echo "cache_key=$(printf 'cached_filings -%s-%s.json' "${{ matrix.site }}" "${{ github.ref_name }}" | tr -cs 'A-Za-z0-9._-' '_')" >> $GITHUB_OUTPUT
6565
6666 - name : Scan site (${{ matrix.site }})
6767 uses : ./
@@ -78,28 +78,28 @@ jobs:
7878 token : ${{ secrets.GH_TOKEN }}
7979 cache_key : ${{ steps.cache_key.outputs.cache_key }}
8080
81- - name : Retrieve cached findings
81+ - name : Retrieve cached filings
8282 uses : ./.github/actions/gh-cache/restore
8383 with :
8484 path : ${{ steps.cache_key.outputs.cache_key }}
8585 token : ${{ secrets.GITHUB_TOKEN }}
8686
87- - name : Add PR URLs to findings
87+ - name : Add PR URLs to filings
8888 uses : actions/github-script@v8
8989 with :
9090 github-token : ${{ secrets.GITHUB_TOKEN }}
9191 script : |
9292 const fs = require('fs');
93- if (!process.env.FINDINGS_PATH || !fs.existsSync(process.env.FINDINGS_PATH )) {
94- core.info("Skipping 'Add PR URLs to findings ' (no cached findings ).");
93+ if (!process.env.CACHE_PATH || !fs.existsSync(process.env.CACHE_PATH )) {
94+ core.info("Skipping 'Add PR URLs to filings ' (no cached filings ).");
9595 return;
9696 }
97- const findings = JSON.parse(fs.readFileSync(process.env.FINDINGS_PATH , 'utf-8'));
98- for (const finding of findings ) {
99- if (!finding.issueUrl ) {
97+ const filings = JSON.parse(fs.readFileSync(process.env.CACHE_PATH , 'utf-8'));
98+ for (const filing of filings ) {
99+ if (!filing?.issue.url ) {
100100 continue;
101101 }
102- const { owner, repo, issueNumber } = /https:\/\/github\.com\/(?<owner>[^/]+)\/(?<repo>[^/]+)\/issues\/(?<issueNumber>\d+)/.exec(finding.issueUrl ).groups;
102+ const { owner, repo, issueNumber } = /https:\/\/github\.com\/(?<owner>[^/]+)\/(?<repo>[^/]+)\/issues\/(?<issueNumber>\d+)/.exec(filing.issue.url ).groups;
103103 const query = `query($owner: String!, $repo: String!, $issueNumber: Int!) {
104104 repository(owner: $owner, name: $repo) {
105105 issue(number: $issueNumber) {
@@ -117,35 +117,35 @@ jobs:
117117 const timelineNodes = result?.repository?.issue?.timelineItems?.nodes || [];
118118 const pullRequestNode = timelineNodes.find(n => n?.source?.url || n?.subject?.url);
119119 if (pullRequestNode) {
120- finding.pullRequestUrl = pullRequestNode.source?.url || pullRequestNode.subject?.url;
120+ filing.pullRequest = { url: pullRequestNode.source?.url || pullRequestNode.subject?.url } ;
121121 } else {
122- core.info(`No pull request found for issue: ${finding.issueUrl }`);
122+ core.info(`No pull request found for issue: ${filing.issue.url }`);
123123 }
124124 }
125- fs.writeFileSync(process.env.FINDINGS_PATH , JSON.stringify(findings ));
125+ fs.writeFileSync(process.env.CACHE_PATH , JSON.stringify(filings ));
126126 env :
127- FINDINGS_PATH : ${{ steps.cache_key.outputs.cache_key }}
127+ CACHE_PATH : ${{ steps.cache_key.outputs.cache_key }}
128128
129129 - name : Validate scan results (${{ matrix.site }})
130130 run : |
131131 npm ci
132132 npm run test
133133 env :
134134 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
135- FINDINGS_PATH : ${{ steps.cache_key.outputs.cache_key }}
135+ CACHE_PATH : ${{ steps.cache_key.outputs.cache_key }}
136136
137137 - name : Clean up issues and pull requests
138138 if : ${{ always() }}
139139 shell : bash
140140 run : |
141141 set -euo pipefail
142142 if [[ ! -f "${{ steps.cache_key.outputs.cache_key }}" ]]; then
143- echo "Skipping 'Clean up issues and pull requests' (no cached findings )."
143+ echo "Skipping 'Clean up issues and pull requests' (no cached filings )."
144144 exit 0
145145 fi
146146 jq -r '
147147 (if type=="string" then fromjson else . end)
148- | .[] | .issueUrl , .pullRequestUrl
148+ | .[] | .issue.url , .pullRequest.url
149149 | select(. != null)
150150 ' "${{ steps.cache_key.outputs.cache_key }}" \
151151 | while read -r URL; do
@@ -162,7 +162,7 @@ jobs:
162162 env :
163163 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
164164
165- - name : Clean up cached findings
165+ - name : Clean up cached filings
166166 if : ${{ always() }}
167167 uses : ./.github/actions/gh-cache/delete
168168 with :
0 commit comments