Skip to content

Commit 84d9c1b

Browse files
fix: use file-based SARIF upload to avoid arg length limits
Large SARIF files exceeded OS argument length limits when passed inline to gh api. Changed to write gzipped+base64 SARIF to a temp file and pipe via jq --rawfile to gh api --input. Also added continue-on-error on MegaLinter since finding issues is expected. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent ad79651 commit 84d9c1b

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

.github/workflows/code-quality-scan.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ jobs:
2323

2424
- name: Run MegaLinter
2525
uses: oxsecurity/megalinter@v8
26+
continue-on-error: true
2627
env:
2728
VALIDATE_ALL_CODEBASE: true
2829
SARIF_REPORTER: true
@@ -39,13 +40,11 @@ jobs:
3940
env:
4041
GH_TOKEN: ${{ secrets.ORG_ADMIN_TOKEN }}
4142
run: |
42-
SARIF_CONTENT=$(gzip -c megalinter-reports/megalinter-report.sarif | base64 -w0)
43+
gzip -c megalinter-reports/megalinter-report.sarif | base64 -w0 > /tmp/sarif_encoded.txt
4344
COMMIT_SHA=$(gh api repos/devopsabcs-engineering/cq-demo-app-${{ matrix.app }}/commits/main --jq '.sha')
44-
RESPONSE=$(gh api \
45-
--method POST \
45+
jq -n --arg sha "$COMMIT_SHA" --arg ref "refs/heads/main" --rawfile sarif /tmp/sarif_encoded.txt \
46+
'{commit_sha: $sha, ref: $ref, sarif: $sarif}' | \
47+
gh api --method POST \
4648
repos/devopsabcs-engineering/cq-demo-app-${{ matrix.app }}/code-scanning/sarifs \
47-
-f "commit_sha=$COMMIT_SHA" \
48-
-f "ref=refs/heads/main" \
49-
-f "sarif=$SARIF_CONTENT")
50-
echo "Upload response: $RESPONSE"
49+
--input -
5150
echo "Uploaded MegaLinter SARIF to cq-demo-app-${{ matrix.app }}"

0 commit comments

Comments
 (0)