From 331d0b60adc8e8b3ec8d3b6d4514044a47eb7d02 Mon Sep 17 00:00:00 2001 From: Andrea Brancaleoni Date: Sat, 9 Nov 2024 00:18:38 -0800 Subject: [PATCH] actions.yml: results-dir not empty check --- actions/main/action.yml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/actions/main/action.yml b/actions/main/action.yml index 4442c16a..31075d52 100644 --- a/actions/main/action.yml +++ b/actions/main/action.yml @@ -125,5 +125,16 @@ runs: const script = require('${{ github.action_path }}/action.cjs') await script({github, context, inputs, actionPath, core, debug: process.env.DEBUG === 'true'}) - - name: Upload SARIF file + # execute only if the `../results` directory is not empty + - id: results-dir + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 + with: + script: | + const fs = require('fs') + const path = require('path') + const resultsDir = path.join('..', 'results') + const files = fs.readdirSync(resultsDir) + return files.length > 0 + - if: ${{ steps.results-dir.outputs.result == 'true' }} + name: Upload SARIF file uses: github/codeql-action/upload-sarif@v3