diff --git a/action.cjs b/action.cjs index e53ae06b..7819aa5d 100644 --- a/action.cjs +++ b/action.cjs @@ -4,11 +4,17 @@ function hashFiles (filename) { return fs.existsSync(filename) } -module.exports = async ({ github, context, inputs, steps, actionPath, core }) => { +module.exports = async ({ github, context, inputs, actionPath, core }) => { + // changed-files steps + let changedFiles = [] + // reviewdog-enabled-pr steps let reviewdogEnabledPr = false - if (inputs.enabled === 'true' && inputs.baseline_scan_only !== 'false' && steps['changed-files'].outputs.all_changed_files !== '' && process.env.GITHUB_EVENT_NAME === 'pull_request' && context.payload.pull_request.draft === false && context.actor !== 'dependabot[bot]') { + if (inputs.enabled === 'true' && inputs.baseline_scan_only !== 'false' && process.env.GITHUB_EVENT_NAME === 'pull_request' && context.payload.pull_request.draft === false && context.actor !== 'dependabot[bot]') { + const { default: pullRequestChangedFiles } = await import(`${actionPath}/src/pullRequestChangedFiles.js`) + reviewdogEnabledPr = true + changedFiles = pullRequestChangedFiles({ github, owner: context.repo.owner, name: context.repo.repo, prnumber: context.payload.pull_request.number }) } // reviewdog-enabled-full steps let reviewdogEnabledFull = false @@ -23,7 +29,7 @@ module.exports = async ({ github, context, inputs, steps, actionPath, core }) => // Write changed files to file if (reviewdogEnabledPr) { const fs = require('fs') - fs.writeFileSync(`${actionPath}/assets/all_changed_files.txt`, steps['changed-files'].outputs.all_changed_files) + fs.writeFileSync(`${actionPath}/assets/all_changed_files.txt`, changedFiles.join('\0')) } // comments-before steps let commentsBefore = null diff --git a/action.yml b/action.yml index 52e69ae4..24647395 100644 --- a/action.yml +++ b/action.yml @@ -84,14 +84,8 @@ outputs: runs: using: 'composite' steps: - - name: Get changed files - if: ${{ inputs.enabled == 'true' && github.event_name == 'pull_request' }} - id: changed-files - uses: tj-actions/changed-files@0874344d6ebbaa00a27da73276ae7162fadcaf69 # v44.3.0 - with: - separator: '\0' - name: Store reviewdog enabled for PR - if: ${{ inputs.enabled == 'true' && inputs.baseline_scan_only != 'false' && steps.changed-files.outputs.all_changed_files != '' && github.event_name == 'pull_request' && github.event.pull_request.draft == false && github.actor != 'dependabot[bot]' }} + if: ${{ inputs.enabled == 'true' && inputs.baseline_scan_only != 'false' && github.event_name == 'pull_request' && github.event.pull_request.draft == false && github.actor != 'dependabot[bot]' }} id: reviewdog-enabled-pr uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 with: @@ -146,10 +140,9 @@ runs: script: | const actionPath = '${{ github.action_path }}' const inputs = ${{ toJson(inputs) }} - const steps = ${{ toJson(steps) }} const script = require(`${actionPath}/action.cjs`) - await script({github, context, inputs, steps, actionPath, core}) + await script({github, context, inputs, actionPath, core}) - uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 with: